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!

Reports - On No Data Event

Status
Not open for further replies.

jojones

Programmer
Dec 4, 2000
104
AU
I am having troubles making the On No Data Event close a report if it has No Data. Can anyone help me... I just get a message saying that the report cannot be closed whilst it is processing (opening)...

thanks
Jo :) Cheers
Jo Jones
 
Jo -

Instead of closing the report, just cancel it.

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Records Available."
Cancel = True
End Sub

Hope that helps.

John
 
John - thanks - half way there I think. I am opening the report from a form (cmd button OnClick procedure). The report did not open, but I got a error message because I used DoCmd to open the report and then cancelled it On No Data like you suggested, Any ideas.? Should I put an OnError in the On No Data Event? or is there something else I can do.

ta
Jo

Cheers
Jo Jones
 
What I have actually done whilst waiting for response was to add a non visible text box to the report. If the OnNoData event is true I set the value of this text box to "NoData". Then in the Page event of the report I closed the report if the text box value = "NoData"

This is clearly not the best way of doing it, but it did get around my problem. I just want to find out the best way.

thanks
Jo Cheers
Jo Jones
 
Jo - It may not be an elegant solution, but I've always used error trapping for this.

Err_CmdPreview_Click:
If Err = 2501 Then
Err.Clear 'If report is closed because there's no data,
'don't report an error
Else
MsgBox Err.Description
End If
Resume Exit_CmdPreview_Click


If you find a better way, please post it. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top