Msgbox!

  • Thread starter Thread starter Floyd Forbes
  • Start date Start date
F

Floyd Forbes

How do I put a msgbox behind a command button on a form to cancel the
printing of a report. I have a subform on a main form with a command button.
When the user click the command button it will print the data in the
subform.
On click I would like a msgbox(" Are you sure that you want to
print?",vbyesno).
If no cancel.

Floyd
 
Something like this may work.

Private Sub CommandButtonName_Click()
If vbYes = MsgBox("Are you sure that you want to print " & _
"this report?", vbQuestion + vbYesNo, "Print?") Then _
DoCmd.OpenReport "ReportName"
Else
MsgBox "Printing cancelled.", vbInformation, "Cancelled"
End If
End Sub
 
Sorry..... delete the _ character after the Then word in the "If" step. (I
was writing the code for one example, and then decided to add the ElseIf to
make it "better"!).


Private Sub CommandButtonName_Click()
If vbYes = MsgBox("Are you sure that you want to print " & _
"this report?", vbQuestion + vbYesNo, "Print?") Then
DoCmd.OpenReport "ReportName"
Else
MsgBox "Printing cancelled.", vbInformation, "Cancelled"
End If
End Sub
 
Back
Top