Hi guys
When I write the following code then it prints off the documents but after that it throws the error message
"Microsoft Access has encountered a problem and needs to close.We are sorry for the inconvenience."
I hope anyone can help me to solve this problem.
Thanks
When I write the following code then it prints off the documents but after that it throws the error message
"Microsoft Access has encountered a problem and needs to close.We are sorry for the inconvenience."
Code:
Private Sub btnPrintRequests_Click()
On Error GoTo Err_btnPrintRequests_Click
If cmbDept.Value <> "" Then
Else
MsgBox "Select a Dept name.", vbCritical, "Dept Name is not selected"
cmbDept.SetFocus
Exit Sub
End If
If MsgBox("The System will now attempt to print two Set of Reports on your default printer." & vbCrLf & vbCrLf & _
"If you want to change your Default Printer or Its settings then do so; and then click OK, " & vbCrLf & _
"Click Cancel, If you do not want to Print this report Now. " & _
"", vbInformation + vbOKCancel, "Change Your Printer Settings before clicking OK [Or Cancel]") = vbCancel Then
Exit Sub
End If
Dim stDocName1 As String
Dim stDocName2 As String
Dim mysCriteria As String
Dim topLabelOnReport As String
stDocName2 = "FrontSheet Report"
stDocName1 = "PickList Report2"
End If
topLabelOnReport = cmbDept.Value & " Dept ONLY"
DoCmd.OpenReport stDocName1, acViewNormal, , , acDialog, topLabelOnReport
DoCmd.OpenReport stDocName2, acViewNormal, , , acDialog, topLabelOnReport
DoCmd.SetWarnings False
DoCmd.RunSQL Sql
DoCmd.SetWarnings True
End If
Exit_btnPrintRequests_Click:
Exit Sub
Err_btnPrintRequests_Click:
If Err.Number = 2501 Then
Else
MsgBox Err.Description
End If
Resume Exit_btnPrintRequests_Click
End Sub
I hope anyone can help me to solve this problem.
Thanks