Can you please help? This form opens several reports based on the criteria entered - select the report name, and select/enter data to view report.
In each report I have:
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report."
Cancel = True
End Sub
In the form I have:
Private Sub Preview_Click()
On Error GoTo Preview_Click_Err
If IsNull(Me![cmbReport]) Then
MsgBox "You must select a report to run.", vbInformation, "Status"
DoCmd.GoToControl "cmbreport"
Exit Sub
End If
If IsNull(Me![cmbCust]) And Me![cmbCust].Enabled = True Then
MsgBox "You must select a Customer.", vbInformation, "Status"
DoCmd.GoToControl "cmbCust"
Exit Sub
End If
If IsNull([cmbJobType]) And Me![cmbJobType].Enabled = True Then
MsgBox "You must select a Job Type.", vbInformation, "Status"
DoCmd.GoToControl "cmbjobtype"
Exit Sub
End If
If IsNull(Me![BegTransDate1]) And Me![cmbMonth].Enabled = True Then
MsgBox "You must select a Month.", vbInformation, "Status"
DoCmd.GoToControl "cmbMonth"
Exit Sub
End If
If IsNull(Me![cmbYear]) And Me![cmbYear].Enabled = True Then
MsgBox "You must select a Year.", vbInformation, "Status"
DoCmd.GoToControl "cmbYear"
Exit Sub
End If
If Me![cmbYear].Visible = False Then
If IsNull([BegTransDate]) Or IsNull([EndTransDate]) Then
MsgBox "You must enter both beginning and ending date", vbInformation, "Status"
DoCmd.GoToControl "BegTransDate"
Else
If [BegTransDate] > [EndTransDate] Then
MsgBox "Ending date must be greater that Beginning date.", vbInformation, "Status"
DoCmd.GoToControl "BegTransDate"
Else
DoCmd.OpenReport [cmbReport], acViewPreview
End If
End If
Else
DoCmd.OpenReport [cmbReport], acViewPreview
End If
Preview_Click_Exit:
Exit Sub
Preview_Click_Err:
If Err <> 2501 Then MsgBox Err.Description
End Sub
I'm not sure what I'm doing wrong ... can you please help me out?
In each report I have:
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report."
Cancel = True
End Sub
In the form I have:
Private Sub Preview_Click()
On Error GoTo Preview_Click_Err
If IsNull(Me![cmbReport]) Then
MsgBox "You must select a report to run.", vbInformation, "Status"
DoCmd.GoToControl "cmbreport"
Exit Sub
End If
If IsNull(Me![cmbCust]) And Me![cmbCust].Enabled = True Then
MsgBox "You must select a Customer.", vbInformation, "Status"
DoCmd.GoToControl "cmbCust"
Exit Sub
End If
If IsNull([cmbJobType]) And Me![cmbJobType].Enabled = True Then
MsgBox "You must select a Job Type.", vbInformation, "Status"
DoCmd.GoToControl "cmbjobtype"
Exit Sub
End If
If IsNull(Me![BegTransDate1]) And Me![cmbMonth].Enabled = True Then
MsgBox "You must select a Month.", vbInformation, "Status"
DoCmd.GoToControl "cmbMonth"
Exit Sub
End If
If IsNull(Me![cmbYear]) And Me![cmbYear].Enabled = True Then
MsgBox "You must select a Year.", vbInformation, "Status"
DoCmd.GoToControl "cmbYear"
Exit Sub
End If
If Me![cmbYear].Visible = False Then
If IsNull([BegTransDate]) Or IsNull([EndTransDate]) Then
MsgBox "You must enter both beginning and ending date", vbInformation, "Status"
DoCmd.GoToControl "BegTransDate"
Else
If [BegTransDate] > [EndTransDate] Then
MsgBox "Ending date must be greater that Beginning date.", vbInformation, "Status"
DoCmd.GoToControl "BegTransDate"
Else
DoCmd.OpenReport [cmbReport], acViewPreview
End If
End If
Else
DoCmd.OpenReport [cmbReport], acViewPreview
End If
Preview_Click_Exit:
Exit Sub
Preview_Click_Err:
If Err <> 2501 Then MsgBox Err.Description
End Sub
I'm not sure what I'm doing wrong ... can you please help me out?