S
saraqpost
This is driving me crazy! I have looked a posts and MS web and tried
to fix, but I keep getting the 2501 error after I show my No Data
message to the user.
Can someone help? I know I'm new, but this looked easy!
thanks
Sara
Print Preview Button Code:
Private Sub cmdPreview_Click()
On Error GoTo Err_cmdPreview_Click
' Figure out which report the user is requesting and run it
Dim strReportName As String
Select Case Me.fraReports
Case Is = 1
' By First name
strReportName = "rptByFirstName"
Case Is = 2
' By Last name
strReportName = "rptByLastName"
Case Is = 3
' By Location
strReportName = "rptByLocation"
Case Is = 4
' By Date - or range
strReportName = "rptByDate"
Case Is = 5
' By Department
strReportName = "rptByDepartment"
End Select
' Debug goes to this line after No data event - with 2501 error
DoCmd.OpenReport strReportName, acViewPreview
Exit_cmdPreview_Click:
Exit Sub
Err_cmdPreview_Click:
If Err.Number = 2501 Then
Err.Clear
Else
MsgBox Err.Number & " " & Err.Description
End If
Resume Exit_cmdPreview_Click
No Data Event Report Code:
Private Sub Report_NoData(Cancel As Integer)
Dim strDepartment As String
strDepartment =
[Forms]![frmEmployeeSurveyed]![cboDepartment].Column(1)
'Tell the user there is no data
MsgBox "There are no shopping reports for the Department chosen: "
& _
strDepartment
Cancel = True
End Sub
to fix, but I keep getting the 2501 error after I show my No Data
message to the user.
Can someone help? I know I'm new, but this looked easy!
thanks
Sara
Print Preview Button Code:
Private Sub cmdPreview_Click()
On Error GoTo Err_cmdPreview_Click
' Figure out which report the user is requesting and run it
Dim strReportName As String
Select Case Me.fraReports
Case Is = 1
' By First name
strReportName = "rptByFirstName"
Case Is = 2
' By Last name
strReportName = "rptByLastName"
Case Is = 3
' By Location
strReportName = "rptByLocation"
Case Is = 4
' By Date - or range
strReportName = "rptByDate"
Case Is = 5
' By Department
strReportName = "rptByDepartment"
End Select
' Debug goes to this line after No data event - with 2501 error
DoCmd.OpenReport strReportName, acViewPreview
Exit_cmdPreview_Click:
Exit Sub
Err_cmdPreview_Click:
If Err.Number = 2501 Then
Err.Clear
Else
MsgBox Err.Number & " " & Err.Description
End If
Resume Exit_cmdPreview_Click
No Data Event Report Code:
Private Sub Report_NoData(Cancel As Integer)
Dim strDepartment As String
strDepartment =
[Forms]![frmEmployeeSurveyed]![cboDepartment].Column(1)
'Tell the user there is no data
MsgBox "There are no shopping reports for the Department chosen: "
& _
strDepartment
Cancel = True
End Sub