Massage box on Error

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
 
D

Douglas J. Steele

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.
 
S

Steve Schapel

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?
 
C

cage

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.
 
S

Steve Schapel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top