Show a ReportPreview only when there's data in it

J

johan

Goodmorning,

I have a button that opens a report in the previewmode.
When there is no data in the report it shows only the pageheading.
What I want is that when there is no data in the report I don't want
to see the preview.
What should be happen is that when you push the button nothing is
happen.

Perhaps something like an OnOpen module on the report that when
there's no data that it's close directly.

regards,
Johan
 
J

j0hnt52

Hi,
One solution is:

Open the Report in Design mode
Go to Properties and select the Event Tab
You should see On No Data
Select Event Procedure and open the module ... it should look like below:

Private Sub Report_NoData(Cancel As Integer)

End Sub

Add the lines:
MsgBox "Type a message here, no data etc."
DoCmd.CancelEvent

so it looks like:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "Type a message here, no data etc."
DoCmd.CancelEvent
EndSub

Works in 2000 and 2003 ... you could leave out the Message line if you like

Cheers
John
 
Top