ms-access


Search & Replace Null with Value from Select Query (Enter Parameter Value)


I created an Update Query that pulls in Type by ID#; however, if there is no match for all IDs, I want to fill in the blank Types using the most common Type identified from a Select Query. How do I do that without using VB (if possible)? Here is what I attempted (Thanks in advance):
Update Query 1: Match List of IDs and Types (Table 1) to new list of IDs (Table 2). If there is an ID match, then fill in Type on Table 2 with the match from Table 1.
Select Query 1: Identifies all the possibilities of Types on Table 2 and groups them in order of count.
Update Query 2: Identify all Nulls under Type in Table 2 and update them with the Type with the highest count in Select Query 1; however, I am receiving an Enter Parameter Value error.
Here's a quick first attempt. If you post your query SQL, perhaps I could improve upon this.
UPDATE Table2
SET Table2.Type = DLookUp("[Type]","Select Query 1",
"[CountOfType] = (SELECT Max([CountOfType]) FROM [Select Query 1])")
WHERE (Table2.Type Is Null)
Note 1: If there are more than one Type value that is most common (i.e. multiple type values have the same count in [Select Query 1]) this solution will randomly select one of them.
Note 2: This does not require a separate VBA module nor writing your own VBA function. However, DLookup is an Access Domain Aggregate Function and is not a native SQL function, so technically is called and executed within Access VBA engine. Such functions can be extremely useful and powerful, reducing the number of queries you have to write and maintain to get certain tasks done. It is possible, however, to create a set of additional queries that will accomplish the same task using "pure" SQL.

Related Links

How to add a menu item to the default right click context menu
ASP Access Database web site on Windows 2008 Server running IIS 7
How to populate field descriptions in MS Access
Version control for VBA file
Mystery HAVING clause
MS Access 2003 - Sparkline Graphs in Microsoft Access
How to extract the schema of an Access (.mdb) database?
Using loop in a Access Query
Access 2007 Empty Query Quirk
MS Access: How can I automatically reduce Text columns to an appropriate size for the data stored in them?
No max(x,y) function in Access
Why does a report throw an error when the corresponding query doesn't?
Programmatically Search an Access Listbox control's Items Based Off of a Textbox Entry
Auto populate a combobox
How can I add a button to an Access report to export it to Excel / PDF?
Access Caching ODBC connection settings

Categories

HOME
vim
winforms
variables
date
asp.net-core
blogger
openstack
platform-builder
syntax
jsp-tags
infragistics
retrofit
flyway4
convolution
podio
izpack
floating-action-button
windows-phone-7
fallback
windows-server-2012
iron-router
decomposition
dynamics-crm-online
designer
workload-scheduler
facebook-page
http-status-code-504
evopdf
flux
oxyplot
samoa
scichart
lldb
grails3
autocad-plugin
paging
jasonette
functional-testing
arabic
numerical-methods
fish
uninstall
linkerd
elasticsearch-net
facebook-apps
tasklet
file-rename
nameservers
airconsole
calibre
usbserial
vsts-build-task
normal-distribution
sequential
jmonkeyengine
http-digest
lto
unobtrusive-validation
greenrobot-eventbus
graphenedb
google-closure
android-mediaprojection
http-redirect
s
long-polling
network-flow
hibernate-tools
mplayer
colorama
titanium-android
topbeat
parallel-data-warehouse
firmata
instant
vmware-tools
httplistener
phishing
disque
ubuntu-10.04
thredds
tmuxinator
varargs
appfabric-cache
apache-commons-fileupload
npapi
modalpopup
qpainter
codeigniter-url
relocation
phalanger
asp.net-web-api-odata
eol
valuechangelistener
typo3-neos
openlaszlo
uv-mapping
apc
web2py-modules
ftps
excel-2003
jplaton
clipper
mhtml
isnullorempty
gil
venn-diagram
ocx
uiviewanimation-curve
windows-phone-7.1.1
subscript
vdsp
f#-powerpack
appender
self-extracting
disclosure
actionview
fluent-interface
nhibernate.search
firefox-5
libs
adrotator
data-driven
project-hosting
w3wp
commodore

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App