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!

Goto label for error handling 1

Status
Not open for further replies.

xsnrg

Technical User
Jun 15, 2004
44
US
I have some reports that when they are run, if there is no data, return an ugly error.

I want to make my own error dialog box in this case so I attempted the following...

On Error GoTo Rpt_NoData
code for running the report

exit_Rpt:
End Sub

Rpt_NoData:
MsgBox "There are no records", etc...
Resume exit_Rpt

But I'm getting a compile error on the line...
On Error GoTo Rpt_NoData
The error says the label is not defined...

Did I miss something silly here... this should work.
 
Try:

[tt]On Error GoTo Rpt_NoData
code for running the report

exit_Rpt:
exit Sub

Rpt_NoData:
if err.number=2501 then
MsgBox "There are no records"
else
msgbox err.description
end if
Resume exit_Rpt
End Sub[/tt]

Roy-Vidar
 
You can trap the error within the report itself via the OnNoData property of the report. Stick your own message there and set Cancel=True.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top