Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing an Error Message

Status
Not open for further replies.

dpye

Technical User
Mar 24, 2003
31
CA
I presently have a form setup where you enter the criteria then select the report you want to view. This previews a report which is based off a query that uses variables as criteria passed to it from the reporting form. All this works fine when there is data available. This report also has some calculated fields on it and unless there is data available it just print #error# in place of the calculation.

Can I control this so that after they select the criteria, a date range and supervisor name, and choose the report it tells them there is no information to display. Another alternative would be to have it print a friendly message on the report other than #error#.

Any ideas would be greatly appreciated
 
If there are no records, then in the OnNoData event of the report, put code like this:
Code:
MsgBox "No data found for this report"
Cancel = True
This way, the report will not be generated at all......
 
Thanks for the quick response.....

I didn't realize that event existed. However there is still one issue. The message that there is no data is generated but then runtime 2501. It believe it tries to open the report despite the fact the action was canceled. Can I trap this error also.

Thanks.
 
Sorry, I forgot about that error. Here's an excellent FAQ by Garridon that covers it:

FAQ703-1594
 
The FAQ mentioned is great except I think there is suppose to be a section called Exit_cmdbutton where cmdbutton is the name of the button I'm using. The reason I say this is because it keeps erroring out there becuase it doesn't know where to go.

Do you know if there is something missing in that code or am I not reading this right?

Thanks.
 
Sorry, about the delay in replying to this but I did manage to figure this out. There was a typo on my part. Thanks for the help
 
I have a similar problem but my #Error message is coming up in a subreport because of no data. I don't want to cancel the entire report, I just want a 0 to show up where the #Error is showing up in my calculated control. Any suggestions?
 
You might want to try the Nz function. It will return a 0 if the value is null:
Code:
=Nz([YourFieldName],0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top