Show a ReportPreview only when there's data in it

  • Thread starter Thread starter johan
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top