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

Textfield in Access 2003 query replaced by squares and asian symbols
Where do I put Access vba code to only fire when physically printing?
Loop through Access tables
Pass Parameter to Stored Procedure
Access 2007 VBA GoToRecord issue
MS Access 2012 Unresponsive to clicks when it has focus on citrix
Error 3155 (ODBC--insert on a linked table 'SAMPLE' failed)
I keep on getting an error 13 type mismatch error, How can I get it out?
MS Access Mark Duplicates in order of appearance
MS access: how to embed JPEG images and preview them?
Problems implementing basic VBA in Access 2007
Access query with unionall or crosstab in asp not working
Why does a datasheet view show only 100 records when based on sorted and filtered adodb recordset
Import MS Word Form Field to Access - Missing Reference?
MS Access forms Denied connection to SQL Express Backend
How can I test and handle a #Func! error from within a query?

Categories

HOME
compiler-construction
pypi
image-processing
tinymce
iot
electron
read-eval-print-loop
rubygems
twitter-bootstrap-4
datastax-java-driver
azure-media-services
constraint-programming
metatrader4
adobe-analytics
nano-server
wheelnav.js
export-to-csv
gz
size
flask-wtforms
windows-server-2012
worldwind
seaborn
oxyplot
nhibernate-envers
java-3d
microsoft-r
java-7
sqlcipher
spark-jobserver
info.plist
saas
atlassian-crucible
gitignore
frame
stormpath
ecto
.net-4.0
jspresso
perlin-noise
vsts-build-task
cloud-code
event-driven
twitch
impersonation
trim
mesos-chronos
jvm-languages
qwt
rdfs
darcs
crosswalk-runtime
root-framework
cubes
elements
gstreamer-0.10
fputcsv
whois
associative-array
browser-link
sdhc
collapse
android-listview
map-projections
0xdbe
ami
composite
geonetwork
facebook-graph-api-v2.4
website-monitoring
clicktag
oxwall
xc16
google-style-guide
markers
rdl
rebol3
comexception
datagridviewcolumn
farseer
xsockets.net
dexterity
sharp-repository
enterprisedb
wse3.0
netbeans-6.9
custom-backend
coercion
psi
yetanotherforum
datareader
google-friend-connect
dmx512
revisions
castle-monorail
ncqrs
firefox-5
database-management
photoshop-cs4
mtj
ajax-forms

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