Trap Error Module

D

Dave Elliott

Is there a module to trap errors for access? Using access 2002 db in 2000
format service pack 3
i.e. replace access standard error message globally?
Make it so debug window cant popup and access standard error message does
not popup!
Example; The report already has code for no data: So I get (2) messages.
DoCmd.SetWarnings False (Used fo Report, no data)
Cancel = -1
MsgBox "There are no records for this request"

DoCmd.SetWarnings True

On Error GoTo Err_Command173_Click (Used for form if Statement exists)
Dte2 = Date
DoCmd.OpenReport "RMothStatmnt", acPreview, "",
"[CustID]=[Forms]![Customers]![CustID]"

Exit_Command173_Click:
Exit Sub

Err_Command173_Click:
MsgBox Err.Description
Resume Exit_Command173_Click
 
A

Albert D. Kallal

If a report is cancelled, then the call ing code that opened the report will
experience an error.

Remove your error code handling...and simple set your code to ignore the
error

on error resume next
DoCmd.OpenReport "RMothStatmnt", acPreview,
"","[CustID]=[Forms]![Customers]![CustID]"

So, the above ignores the fact that the report cancelled. Of course, you
have to the code in the report "on no data" event to give the error message,
and set cancel = true...right?

Also, if you always distribute a mde (and you should), then any error that
occurs will NOT re-set your variables. While I should have error handling
everywhere...I don't!

So, my solution is to always use a mde file..and errors don't re-set your
variables...and the application will generally as a result be MUCH more
reliable.
 
E

Eric Cárdenas [MSFT]

From: "Dave Elliott said:
Newsgroups: microsoft.public.access.forms
Subject: Trap Error Module

Is there a module to trap errors for access? Using access 2002 db in 2000
format service pack 3
i.e. replace access standard error message globally?
Make it so debug window cant popup and access standard error message does
not popup!
Example; The report already has code for no data: So I get (2) messages.
DoCmd.SetWarnings False (Used fo Report, no data)
Cancel = -1
MsgBox "There are no records for this request"

DoCmd.SetWarnings True

On Error GoTo Err_Command173_Click (Used for form if Statement exists)
Dte2 = Date
DoCmd.OpenReport "RMothStatmnt", acPreview, "",
"[CustID]=[Forms]![Customers]![CustID]"

Exit_Command173_Click:
Exit Sub

Err_Command173_Click:
MsgBox Err.Description
Resume Exit_Command173_Click
--------------------
To trap errors in Access you need an On Error Goto command in each of your
modules. Then you need a "Errorhandler:" section in your module to handle
those errors.

There is no global replace of all error messages.

Regards,
 

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