Massage box on Error

  • Thread starter Thread starter cage
  • Start date Start date
C

cage

In Access 2003 I have a simple Macro that runs a “append queryâ€. I have
suppressed any error massage’s that MS Access would display with
“SetWarnings†but I would like a pop up box with a massage I put in it to
come up if the query did not run successful. Is there a way to do this?

Thanks
 
Using a macro? I don't think it's possible.

It is possible, however, using VBA.

Use the Execute method of the query object, together with the dbFailOnError
parameter. That will cause a trappable error to be raised if the query
fails. Put your custom error message in the routine's Error Handling
section.
 
Cage,

It depends a bit on what you mean by "did not run successful". Can you
give examples of what problems you would be trying to detect?
 
I have the Append query updating a date range, and if this date range already
exists the append query will fail do to a primary key conflict.
 
Cage,

You mean the date field is the primary key?

Anyway (unless you turn Warnings back on), I think the only way to
handle that would be to test first to see if the date range already
exists. This will probably be fairly easy... you would just need to
make a query based on your append query plus the table the append is
writing to, and see if it returns any records. I imagine this may be
via setting a macro Condition using the DCount() function. Sorry, can't
be more specific than that, without knowing the details of what you are
doing.
 
Back
Top