Error trap for a report with no data opened from a Switchboard button

Keith Nichols

Registered User.
Local time
Today, 13:17
Joined
Jan 27, 2006
Messages
431
Hi,

If a user runs a report with parameters from the switchboard and there is no data for that report, the report displays with errors. I would like to trap the error, display a message and return the user to the switchboard.

All the threads I have found relating to this tell me that the error trap needs to be wherever the report was called from, not the "On no data" event of the report itself. Have I understood this correctly? :confused:

If the error trap cannot be on a report event, how do I attach it to the Switchboard buttons? :confused:

Is there a more sensible way to achieve this? :confused:

I did find one thread that solved the problem, but the solution was to call a macro with error trapping built in, that then called the report. I have many reports and I think this solution would need a macro (or module) for each report, something I am reluctant to get into.

Thanks in advance.
 
Hi Keith,

I use the following code and it works fine for me, returning to the switchboard.

Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data to print. Please check selection criteria.", , Me.Caption
Cancel = True

End Sub

Obviously you can change the message text to suit your situation.

Dave
 
"Cancel = True" - works a treat.

Chisamba said:
Hi Keith,

I use the following code and it works fine for me, returning to the switchboard.

Dave,

It works beautifully. Thanks. :)

Maybe it is an Access 2003 thing. If posts on this forum are anything to go by, people seem to have had all sorts of problems with this issue and come up with some very involved solutions, yet the solution you provided is very simple. Go figure.
 

Users who are viewing this thread

Back
Top Bottom