no data in reports

  • Thread starter peljo via AccessMonster.com
  • Start date
P

peljo via AccessMonster.com

I am opening a report listing the sales for a given client.When however there
are no sales for a given client, the report is opened indeed but it is
written error and the picture is rather ugly. Could i set up some filter on
opening of the report, and if there are no data,just not open the report ? I
will have a cleaner picture then
 
F

fredg

I am opening a report listing the sales for a given client.When however there
are no sales for a given client, the report is opened indeed but it is
written error and the picture is rather ugly. Could i set up some filter on
opening of the report, and if there are no data,just not open the report ? I
will have a cleaner picture then

Code the Report's OnNoData event:

MsgBox "No data for this customer."
Cancel = True

If the report has been opened using code, this will cause an error
2501.
You need to trap the error in whatever code event you used to open the
report.

On Error goTo Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview

Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub
 
P

peljo via AccessMonster.com

An excellent reply !!! Many thanks !
Code the Report's OnNoData event:

MsgBox "No data for this customer."
Cancel = True

If the report has been opened using code, this will cause an error
2501.
You need to trap the error in whatever code event you used to open the
report.

On Error goTo Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview

Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub
 

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

Top