Cancel Append Queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.. I have a command button on a form that runs three append queries on
three different tables. In the event of a "duplicate record" error, how can
I trap the access error message and cancel the event? I have experimented
but have been unable to come up with a solution.
 
Use the Execute method, with the dbFailOnError switch:
Dim db As DAO.Database
Set db = dbEngine(0)(0)
db.Execute "Query1", dbFailOnError
db.Execute ...

Include error handling. If there is an error you can then jump out of the
routine.

For a complete all-or-nothing result, you could use a transaction around all
3 so you can rollback if there is an error. Details and example:
http://members.iinet.net.au/~allenbrowne/ser-37.html
 
Appreciate the help!

Allen Browne said:
Use the Execute method, with the dbFailOnError switch:
Dim db As DAO.Database
Set db = dbEngine(0)(0)
db.Execute "Query1", dbFailOnError
db.Execute ...

Include error handling. If there is an error you can then jump out of the
routine.

For a complete all-or-nothing result, you could use a transaction around all
3 so you can rollback if there is an error. Details and example:
http://members.iinet.net.au/~allenbrowne/ser-37.html
 
Hello again.. I tried the code, but I'm getting the error message "Too few
parameters, Expected 2". Can you help with this?
 
Back
Top