Cancelling a report if no data

RedSkies

Registered User.
Local time
Today, 00:06
Joined
Aug 17, 2000
Messages
48
Hi all,

I have a couple of issues I need some direction on and I'm under a bit of a time crunch so I'm not above begging!
wink.gif
Here's some of the background info without going into excruciatingly boring detail, so hopefully it's enough to provide an idea of the general structure:

Reports are launched from a form which allows the user to select from a list of possible reports and either preview or print by clicking respective buttons. On each report's On Open event, another form is launched which allows the user to input or select various criteria to customize the report output. Upon clicking the OK button on the criteria form, a number of nested queries are built on the fly based on the criteria selected, yada, yada, yada, and the report is generated.

My question is this: if the the user selects a combination of criteria which produces no data, how do I get a)the report to cancel without running and b)the code to return control to the criteria selection form?

So far, I've tried using a message box which fires from the Report_NoData event. The message box runs correctly but after clicking OK, I get another Access-generated error message that says: "The report could not be viewed because an error occurred.The OpenReport action was canceled."

Note that opening the report is what launches the criteria selection form and not vice versa. I've seen code samples on how to handle this if the report is launched from the criteria form but not the way I have it set up.

Any suggestions would be greatly appreciated. Hopefully I've provided enough detail. If you need more, please let me know.

Thank you!

Anne
 
In your On No Data event of the report you need an error trap to capture err.number 2501. This is generated by the no data event. A simpler way would be add the following line as the first line in the On No Data code:

On Error Resume Next

This will get you past the error message, then maybe you can figure the rest out.

HTH
RDH
 
Sorry to butt in - I placed On Error Resume Next on line 1
Msgbox "Sorry No Data" on line 2.

I didn't get the error message, but My messagebox popped up a second time after clicking OK the first time.

Any ideas why?

Thanks RedSkies & RHicks

Michael Abrams

[This message has been edited by mrabrams (edited 08-17-2000).]

[This message has been edited by mrabrams (edited 08-17-2000).]
 

Users who are viewing this thread

Back
Top Bottom