View alternate report when first report is blank

G

Guest

I am working on a database that reviews and reports shipping performance
issues. A report run via selected date range will show all orders that are
considered late, according to specific criteria. A subreport will show the
percentage of late vs. on time. The goal of course is to have the report
show 100% on time - with no records indicating lateness.

The problem: When the date range selected is such that no orders are late,
the report will come up with #error# in several text boxes and no
information. True, since no orders are late. However, I would like that
report to instead show "All Orders On Time" or have another report appear
that says the above statement.

I created a macro that would run in the report event property "On No Data"
which would pull up a second report with the label "All Orders On Time", but
the original report with #error# still comes up with it. I tried to modify
the macro, so that it would close the #error# report first and then pull up
the second report, but that would not work either.

Any ideas/suggestions?!
 
F

fredg

I am working on a database that reviews and reports shipping performance
issues. A report run via selected date range will show all orders that are
considered late, according to specific criteria. A subreport will show the
percentage of late vs. on time. The goal of course is to have the report
show 100% on time - with no records indicating lateness.

The problem: When the date range selected is such that no orders are late,
the report will come up with #error# in several text boxes and no
information. True, since no orders are late. However, I would like that
report to instead show "All Orders On Time" or have another report appear
that says the above statement.

I created a macro that would run in the report event property "On No Data"
which would pull up a second report with the label "All Orders On Time", but
the original report with #error# still comes up with it. I tried to modify
the macro, so that it would close the #error# report first and then pull up
the second report, but that would not work either.

Any ideas/suggestions?!

It's not clear whether you just want a message to alert the user that
there was no data or you want a printed copy of the report that says
there is no data.

To display just a message....
Code the report's OnNoData event:
MsgBox "There was no data in this time period."
Cancel = True

If this report has been opened from an event on a form, you must add
error handling to that form event to trap error 2501.


On Error Goto Err_Handler
DoCmd.OpenForm "FormName"
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub
End Sub

To actually print the report with a label that says there was no data,
add a label to the report header. Set it's caption to "No data for
this time period.".
Name it LabelNoData. Make it Not Visible.

Code the Report OnNoData event:

LabelNoData.Visible = True
OtherControlInReportHeader.Visible = False
etc.
Me.Section(0).Visible = False ' Detail Section
Me.Section(3).Visible = False ' Page Header
Me.Section(4).Visible = False ' Page Footer\
etc.
 
G

Guest

Thanks! Your second suggestion was just what I wanted. I had never
attempted this type of thing before and I appreciate the vb language to do
so! I'm working on this at a different building, so I will let you know in
another reply if there are any problems. But this looks like exactly what I
need.
 
G

Guest

I was able to follow your suggestion and the report is working just great. I
really appreciate your help! Thanks!!
 

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