No Report Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
I was wondering if there was any way to have a report not show at all if
there is no data returned for it? For example, I have report labels set to
print for certain items (each report for a separate item), but if there are
no items associated, the report will still print with the #Error display in
all of the fields. Is there a way to not even have the report display or
print?
Any help is greatly appreciated. Thanks!
-gary
 
Gary said:
I was wondering if there was any way to have a report not show at all if
there is no data returned for it? For example, I have report labels set to
print for certain items (each report for a separate item), but if there are
no items associated, the report will still print with the #Error display in
all of the fields. Is there a way to not even have the report display or
print?


Use the report's NoData event to cancel the report.

Cancel = True

If you are using a form button to open the report
(recommended), then add error handling to the click event
and ignore error number 2501
 
Awesome! Thank you!
I do have instances where the command button opens more than one report.
How would I change the error handler to check for each report I am attempting
to open?
Thanks!
-gary
 
Since all you want to do is ignore the error, you shouldn't
have to do anything. (The error handling code has no idea
what code caused the error.)
 
Hi again,
Sorry, I realized my question did not make sense. I am using a command
button to open two reports. Each report has the NoData event Cancel=True
What I am noticing is if the first report has no data, it will prevent the
second report from coming up at all. Is there a way around this by changing
the No Data event on the report?
Thanks again!
-gary

Marshall Barton said:
Since all you want to do is ignore the error, you shouldn't
have to do anything. (The error handling code has no idea
what code caused the error.)
--
Marsh
MVP [MS Access]


Gary said:
Awesome! Thank you!
I do have instances where the command button opens more than one report.
How would I change the error handler to check for each report I am attempting
to open?
 
I suspect that your error handling code is just exiting
instead of using Resume Next

On Error GoTo ErrorHandler
. . .
ExitHere:
Exit Sub

ErrorHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select
End Sub
 
Awesome, thank you so much!!
-gary

Marshall Barton said:
I suspect that your error handling code is just exiting
instead of using Resume Next

On Error GoTo ErrorHandler
. . .
ExitHere:
Exit Sub

ErrorHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select
End Sub
--
Marsh
MVP [MS Access]


Gary said:
Sorry, I realized my question did not make sense. I am using a command
button to open two reports. Each report has the NoData event Cancel=True
What I am noticing is if the first report has no data, it will prevent the
second report from coming up at all. Is there a way around this by changing
the No Data event on the report?
 
Back
Top