Solved

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

Posted on 2013-05-30
4
563 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 - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Graham Mandeno, your solution works great...exactly as you said it would.

I do not get the error anymore.

Thank you.
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
"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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Outlook Free & Paid Tools
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.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now