David Ball
Registered User.
- Local time
- Tomorrow, 02:11
- Joined
- Aug 9, 2010
- Messages
- 230
Hi,
The code below works to open a report (after some help from PBaldy).
Private Sub CmdSubsystem_Click()
If IsNull(TxtSubsystem.Value) Then
MsgBox "You did not enter a Subsystem number", vbOKOnly + vbDefaultButton2 + vbCritical, "No Criteria Entered"
Else
DoCmd.OpenReport "rptTESTInfoBySubsystem", acViewReport, "qryTestDetailsBySubsystem", " Subsystem = '" & TxtSubsystem.Value & " ' "
End If
End Sub
I have an On No Data event set up on the report to show a message and Cancel the report if there is no data returned. See below:
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No PAS Serial Test Related to Subsystem Entered", vbCritical, "No Data Found"
Cancel = True
End Sub
The problem is if there is no data, the message shows and when I select OK it shows this error:
Run-time error ‘2501’:
The openreport action was canceled.
What do I need to change to get this working so that after I press OK the report (with no data) doesn’t open and no error occurs?
Thanks very much
Dave
The code below works to open a report (after some help from PBaldy).
Private Sub CmdSubsystem_Click()
If IsNull(TxtSubsystem.Value) Then
MsgBox "You did not enter a Subsystem number", vbOKOnly + vbDefaultButton2 + vbCritical, "No Criteria Entered"
Else
DoCmd.OpenReport "rptTESTInfoBySubsystem", acViewReport, "qryTestDetailsBySubsystem", " Subsystem = '" & TxtSubsystem.Value & " ' "
End If
End Sub
I have an On No Data event set up on the report to show a message and Cancel the report if there is no data returned. See below:
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No PAS Serial Test Related to Subsystem Entered", vbCritical, "No Data Found"
Cancel = True
End Sub
The problem is if there is no data, the message shows and when I select OK it shows this error:
Run-time error ‘2501’:
The openreport action was canceled.
What do I need to change to get this working so that after I press OK the report (with no data) doesn’t open and no error occurs?
Thanks very much
Dave