I have a button on a print dialog form which previews or prints reports. The code on the "printbutton" is OnClick event.
Private Sub printbutton_Click()
Dim ReportName, DateFieldName
Select Case Me.PickReport
Case 1
ReportName = "rpt_deliveries"
DateFieldName = "DeliveryDate"
Case 2
DateFieldName = "FiscalPeriod"
ReportName = "Basic Product List"
End Select
DoCmd.OpenReport _
ReportName:=ReportName, _
view:=Me.OutputMode, _
Wherecondition:=DateFieldName & " Between #" & _
Me.StartDate & "# AND #" & _
Me.EndDate & "#"
End Sub
In the report named rpt_deliveries in the OnNoData event I have the following code:
MsgBox "There is no data for this report"
Cancel = True
Everything works fine when there is no data. (i.e. the msgbox pops up and I hit OK button) However, I then get an error with the following code from the print dialog form highlighted in yellow:
DoCmd.OpenReport _
ReportName:=ReportName, _
view:=Me.OutputMode, _
Wherecondition:=DateFieldName & " Between #" & _
Me.StartDate & "# AND #" & _
Me.EndDate & "#"
I need something that will close down the form or better yet, ignor the error since there is no OnNoData event on the print dialog box.
Any Suggestions?
Private Sub printbutton_Click()
Dim ReportName, DateFieldName
Select Case Me.PickReport
Case 1
ReportName = "rpt_deliveries"
DateFieldName = "DeliveryDate"
Case 2
DateFieldName = "FiscalPeriod"
ReportName = "Basic Product List"
End Select
DoCmd.OpenReport _
ReportName:=ReportName, _
view:=Me.OutputMode, _
Wherecondition:=DateFieldName & " Between #" & _
Me.StartDate & "# AND #" & _
Me.EndDate & "#"
End Sub
In the report named rpt_deliveries in the OnNoData event I have the following code:
MsgBox "There is no data for this report"
Cancel = True
Everything works fine when there is no data. (i.e. the msgbox pops up and I hit OK button) However, I then get an error with the following code from the print dialog form highlighted in yellow:
DoCmd.OpenReport _
ReportName:=ReportName, _
view:=Me.OutputMode, _
Wherecondition:=DateFieldName & " Between #" & _
Me.StartDate & "# AND #" & _
Me.EndDate & "#"
I need something that will close down the form or better yet, ignor the error since there is no OnNoData event on the print dialog box.
Any Suggestions?