Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-05-30
4
Medium Priority
?
649 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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 1600 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
New style of hardware planning for Microsoft Exchange server.
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  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

618 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