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

Access 2010 cascading combo boxes runtime error 424
Access Month Calendar View
Shapefile to MDB with custom field structure [duplicate]
Query JET 4 database with SSIS
Microsoft Access 2010: Query Criteria moving
Is there a way to create an Access database from a Visio database model?
Access: insert multiselect box values into database
ms access extra table indexes
Recordsource vs Recordset for Unbound Forms
Access Database Remote Connection
How to programmatically convert Access 1997 .mdb to Access 2007 .accdb
Microsoft Access Duplicate Output Destination workaround
Ms access : calculated field from other table
Finding where an object in access is referenced
Queries for Importing Data from Flat-File Tables to Many-to-Many Relationship
Removing dead space from a report if a sub-report is hidden

Categories

HOME
proxy
openstack
plot
relay
grep
google-docs
google-oauth
directx
multiple-records
node-notifier
gorm
adobe-analytics
resize
telephony
propel
introduction
dbext
csrf-protection
facebook-instant-articles
url-scheme
procdump
catel
winrt-xaml-toolkit
cloud-code
hot-module-replacement
neuroscience
xenforo
uft-api
azure-ml
sfdc
quadratic-programming
spring-security-kerberos
fakeiteasy
mime
total-commander
reactive-cocoa-5
babel-core
flickr-api
ionicons
recursive-datastructures
setter
linode
nbconvert
iso8601
titanium-android
query-performance
cubes
nxt
slicknav
dstu2-fhir
thrust
mongocsharpdriver
nsviewcontroller
sigabrt
captivenetwork
apachebench
design-by-contract
photobucket
energy
r-tree
google-places
qdialog
map-projections
responsive-images
service-accounts
php-ci
mono-embedding
streambase
npapi
has-many-through
poller
hyprlinkr
concurrent-collections
page-layout
ora-00911
sharp-repository
pygit2
specification-pattern
javaspaces
parametric-equations
online-compilation
punbb
spyware
horizontal-accordion
h.323
gamequery
revisions
icanhaz.js
preference
text-coloring
port-number
spec#
defensive-programming
geneva-server
.net-1.0
ajax-forms





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