no data in reports

  • Thread starter Thread starter peljo via AccessMonster.com
  • Start date 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
 
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
 
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
 
Back
Top