N
Nadir
Hi,
I have this code below that works fine when clicking on OK but when
clicking on the "Cancel" button or the "X" to close I get the Type
Mismatch error. Help!
Thanks.
Option Compare Database
Option Explicit
Private Sub PrintByReport__Click()
On Error GoTo Err_PrintByReport__Click
Dim stDocName As String
Dim intUserRespond As Integer
Dim intReportNumber As Integer
Dim strWhere As String
If Me.Dirty Then 'save any edits
Me.Dirty = False
Else
intReportNumber = InputBox("Please enter the report number you
wish to print", "View BPL by report number")
strWhere = "[BPLReport] = """ & intReportNumber & """"
stDocName = "rptMasterBPLReport"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
intUserRespond = MsgBox("Do you want to print this report?",
vbOKCancel, "Print Report Window")
If intUserRespond = vbOK Then
DoCmd.PrintOut (acPrintAll)
Else
DoCmd.Close
End If
End If
Exit_PrintByReport__Click:
Exit Sub
Err_PrintByReport__Click:
MsgBox Err.Description
Resume Exit_PrintByReport__Click
End Sub
I have this code below that works fine when clicking on OK but when
clicking on the "Cancel" button or the "X" to close I get the Type
Mismatch error. Help!
Thanks.
Option Compare Database
Option Explicit
Private Sub PrintByReport__Click()
On Error GoTo Err_PrintByReport__Click
Dim stDocName As String
Dim intUserRespond As Integer
Dim intReportNumber As Integer
Dim strWhere As String
If Me.Dirty Then 'save any edits
Me.Dirty = False
Else
intReportNumber = InputBox("Please enter the report number you
wish to print", "View BPL by report number")
strWhere = "[BPLReport] = """ & intReportNumber & """"
stDocName = "rptMasterBPLReport"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
intUserRespond = MsgBox("Do you want to print this report?",
vbOKCancel, "Print Report Window")
If intUserRespond = vbOK Then
DoCmd.PrintOut (acPrintAll)
Else
DoCmd.Close
End If
End If
Exit_PrintByReport__Click:
Exit Sub
Err_PrintByReport__Click:
MsgBox Err.Description
Resume Exit_PrintByReport__Click
End Sub