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

Combine code to shorten it
Is it possible to print a query through a form in MS Access?
Where is the Form/Report `Menu` event (that relates to OnMenu) defined in Access?
Access VBA DLookup: Syntax error (missing operator) in query expression
MS Access - Speed Issue
MS Access 2016 - Updating Multiple Tables
Concatenated numbers stuck in scientific notation MS Access
ms access for each field
in access how to draw tables on Report and then export it on word
Automatically adding ID number from different table to new entries?
Access VBA Outlook MAPI- Prevent Record Update if email is not sent
data type mismatch error in criteria expression-ms access
Access Main Form 'Enter Parameter Value'
How to get a combobox2 to display records only relating to the selection made in combobox1?
Ms Access: Running an update query
Access Query that brings up decimal amounts

Categories

HOME
gitlab
session
alfresco
onelogin
convolution
indesign
portia
cross-validation
export-to-csv
postgres-xl
resize
progressive-web-apps
django-admin
tostring
facebook-page
reactive-cocoa
interop
excel-vba-mac
scichart
java-3d
scriptcs
sox
telerik-reporting
facet
uninstall
rst2pdf
xacml
windowbuilder
tasklet
catel
force-layout
simplexml
swisscomdev
hot-module-replacement
fedex
node-gyp
nbconvert
yt-project
nxt
fody
django-debug-toolbar
plottable.js
hill-climbing
ready-api
testng-dataprovider
cloudbees
reactive-banana
lemon
ora-00900
intellij-14
sysinternals
operation
mmc
pretty-print
proj4js
operator-precedence
jquery-layout
mysql-error-1062
bundles
android-2.2-froyo
didselectrowatindexpath
cloud-connect
viadeo
ccss
tidy
web2py-modules
padarn
free-variable
frameset
dotnethighcharts
pendrive
table-footer
disclosure
sql-server-profiler
w3wp.exe
rescale
fixed-width
exchange-server-2003
anti-piracy
scripting-languages

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