Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when running a Append query

Status
Not open for further replies.

webwevers

Programmer
May 10, 2002
15
US
I receive an error message of Can't append all the records in the append query. This is because the user has tryed to enter a duplicate ID number. My question is, I would like to replace the default error message with one of my own making. I can get my error message to come up if the user clicks on No from the default error message. I just would like to get rid of the default message. I still need to trap for the duplicate ID number, this is to let the user know, so using the Setwarnings False and then turning it on will not work. Thanks for any help.
 
Is it your intention to append all records where there is a unique ID only and then provide for a list of the records that have the error Duplicate ID? Please provide a little more information as to would like to do.

You could run a query identifying the duplicates and printing them out first allowing the user to fix the duplicates before the append query runs. This can be done with an inner join Select query. Those records that already have a matching ID will be displayed and printed out. This error report can then be used by the user to fix the records in question. If no duplicate records exist then the append query can run. The following code could be used with some modifications to perform this function. qryDupRercords is just a Select query with an Inner Join between the ID Numbers.

If DCount(1,"qryDupRecords") > 0 then
DoCmd.OpenReport "rptDuplicates"
exit sub
else
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAppendRecords"
DoCmd.SetWarnings True
end if

I hope this helps get you on the right track. Bob Scriver
 
Thanks or the help, that put me on the right track. What I did was first check for duplicates then if not found run the append qry. If it found them then error out to my error message. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top