Solved

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

Posted on 2013-05-30
4
592 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
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

776 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