Solved

How do I suppress the message "...can't append all the records in the append query"

Posted on 2013-05-30
4
603 Views
Last Modified: 2013-05-30
I would like the error message (see attached) to not appear whenever this situation occurs. How can I suppress it? I have already inserted the DoCmd.Set Warnings False but it is still appearing.
Append-Warning.jpg
0
Comment
Question by:geeta_m9
  • 2
4 Comments
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 100 total points
ID: 39209454
Use this code instead to run your action queries :

CurrentDB.Execute "YourActionQueryName", dbFailOnError

Best approach ... and no warning messages, but will show any error that may occur and that you will want to know about.

mx
0
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 400 total points
ID: 39209583
Using the Execute method with dbFailOnError will allow you to trap the error and suppress the message or take some other action, but it will also prevent your query from appending any records at all.  It will have the equivalent effect to clicking "No" in the screenshot you posted.

You should modify your query so that it does not attempt to append records for key fields that already exist.

For example, say your query is as follows:

INSERT INTO Table2 (KeyField, OtherField)
SELECT DISTINCT Field1, Field2 FROM Table1;


This will fail if Field1 in Table1 contains a value that already exists in KeyField in Table2.

To avoid this, add a WHERE clause to select records with values that do NOT exist in a subquery:

INSERT INTO Table2 (KeyField, OtherField)
SELECT DISTINCT Field1, Field2 FROM Table1
WHERE NOT EXISTS( SELECT * FROM Table2 WHERE KeyField=Table1.Field1 );


Then you can use the Execute method and it will not fail.

Best wishes,
Graham Mandeno [Access MVP 1996-2013]
0
 

Author Comment

by:geeta_m9
ID: 39209738
Graham Mandeno, your solution works great...exactly as you said it would.

I do not get the error anymore.

Thank you.
0
 
LVL 75
ID: 39209809
"but it will also prevent your query from appending any records at all"

Personally, I see this as a good thing, especially if I am *expecting* the query to append (etc) all records. I would rather know if it does not, and find out why.

On the other hand, if you are expecting that some records will not get appended, then you can use the SQL that Graham suggested, or trap for that specific error and ignore it.

In all cases,  you need to include error trapping in conjunction with the dbFailOnError.

mx [Access MVP 2009-2013)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you how to use shortcut menus in the Access run-time environment.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question