3

EDIT: Here are two database Files that demonstrate an applied example of the problem:

Example_DBs.zip (Zipped due to 2 link limitation.)

Note: The missing Field in "Not Working.mdb" is intentional. Please have a look at the attached diagram for further clarification.

I'm trying to create a single, Update Query in Access 2007 that does all of these 3 things:

  1. Update (skipping zero-length values)
  2. Append
  3. Automatically handle missing Fields without showing any "Enter Parameter Value" prompts.

I've managed to accomplish the 1st & 2nd items on my own, but I'm stumped on the 3rd. In essence, what I'm looking for is a way of telling Access to automatically use a zero-length/null value for any missing Field(s) the Query encounters, so long as it does not involve manually modifying the Table beforehand. Automation is key. And that's where you guys come in.

Here is a diagram of the desired results from a set of sample Tables:

Sample Tables Diagram

And here is the Update Query's SQL code adjusted for those sample Tables:

UPDATE Table_1 RIGHT JOIN Table_2 ON Table_1.ID = Table_2.ID SET Table_1.ID = NZ([Table_2].[ID],[Table_1].[ID]), Table_1.Company = NZ([Table_2].[Company],[Table_1].[Company]), Table_1.Address = NZ([Table_2].[Address],[Table_1].[Address]), Table_1.Phone = NZ([Table_2].[Phone],[Table_1].[Phone]);

Any help would be greatly appreciated.

  • FYI - It appears that (as of the time of this comment) the link to download the example DBs no longer works (It results in the message "Application AisMDMMInTAOji478kuNxz is unavailable"). – RDFozz Oct 3 '17 at 20:11
1

You can't have 'missing fields' in a query without getting a prompt. Your June updates can not reference the phone column that does not exist and your July can not reference address. You need 2 different queries. If your business logic can't determine which query to run then you can use the Fields Collection of the TableDef object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.