A
Ann
I am working with Access 2002 trying to add code to a report when it opens to
tell the user when there aren't any records to display. It works fine on a
regular report, but I have a report that starts out blank, no query and no
fields, but has two subs on it. I needed to do this because of calculations
done in the footer on different fields. I have added the following code to
the button that opens the report, rptQuestionsOneAndFive.
Private Sub Command30_Click()
On Error GoTo ErrorOpen
DoCmd.OpenReport "rptCalendar", acViewPreview
ExitOpen:
Exit Sub
ErrorOpen:
If Err = 2501 Then
Resume ExitOpen
Else
MsgBox Err.Description
Resume ExitOpen
End If
End Sub
I then added the following code to both of the subreports, subrptQuestionOne
and subrptQuestionFive:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrorHandler
MsgBox "There are currently no records to display.", vbOKOnly
Cancel = True
ExitReport:
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume ExitReport
End Sub
All I get is a blank report since the subs are on a blank report. Is there
a way to still have the message appear if the report still opens but is
blank. I'm a beginner in VB so hopefully it won't be too complex if it can
be done. Thanks in advance for the help.
tell the user when there aren't any records to display. It works fine on a
regular report, but I have a report that starts out blank, no query and no
fields, but has two subs on it. I needed to do this because of calculations
done in the footer on different fields. I have added the following code to
the button that opens the report, rptQuestionsOneAndFive.
Private Sub Command30_Click()
On Error GoTo ErrorOpen
DoCmd.OpenReport "rptCalendar", acViewPreview
ExitOpen:
Exit Sub
ErrorOpen:
If Err = 2501 Then
Resume ExitOpen
Else
MsgBox Err.Description
Resume ExitOpen
End If
End Sub
I then added the following code to both of the subreports, subrptQuestionOne
and subrptQuestionFive:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrorHandler
MsgBox "There are currently no records to display.", vbOKOnly
Cancel = True
ExitReport:
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume ExitReport
End Sub
All I get is a blank report since the subs are on a blank report. Is there
a way to still have the message appear if the report still opens but is
blank. I'm a beginner in VB so hopefully it won't be too complex if it can
be done. Thanks in advance for the help.