G
Guest
Hi guys,
I have a form which has a tick box called Approved. I have a button which
when clicked prints the current record in a report. I want the form to
display an error message whenever the button is clicked if Approved is not
ticked. I have the code:
Private Sub Command41_Click()
Dim stDocName As String
If [Approved] = "0" Then
MsgBox "You are trying print an un-approved quotation. Get it checked!",
vbQuestion + vbOK, "Warning"
End If
stDocName = "Quotations"
DoCmd.OpenReport "quotations", acViewNormal, , "[QuotationID] = " &
Me![QuotationID]
Exit_Quotation_Report_Print_Preview_Clic:
Exit Sub
Err_Quotation_Report_Print_Preview_Click:
MsgBox Err.Description
Resume Exit_Quotation_Report_Print_Preview_Clic
End Sub
Which sort of works, but when I click cancel on the error message, the
document still prints. Also if I cancel the print I get the error message:
Runtime Error '2501'
The open report action was cancelled.
Can someone correct my code for me? Thanks in advance.
I have a form which has a tick box called Approved. I have a button which
when clicked prints the current record in a report. I want the form to
display an error message whenever the button is clicked if Approved is not
ticked. I have the code:
Private Sub Command41_Click()
Dim stDocName As String
If [Approved] = "0" Then
MsgBox "You are trying print an un-approved quotation. Get it checked!",
vbQuestion + vbOK, "Warning"
End If
stDocName = "Quotations"
DoCmd.OpenReport "quotations", acViewNormal, , "[QuotationID] = " &
Me![QuotationID]
Exit_Quotation_Report_Print_Preview_Clic:
Exit Sub
Err_Quotation_Report_Print_Preview_Click:
MsgBox Err.Description
Resume Exit_Quotation_Report_Print_Preview_Clic
End Sub
Which sort of works, but when I click cancel on the error message, the
document still prints. Also if I cancel the print I get the error message:
Runtime Error '2501'
The open report action was cancelled.
Can someone correct my code for me? Thanks in advance.