VB Code to ask If I want to Print Invoice ??

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I have a Categories and Products form that after running some code I want it
to ask me if I want to print the Invoice or not,
i.e. DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70

DoCmd.OpenReport stDocName, acNormal, , stLinkCriteria

If I answer yes, it goes ahead and runs above code, else does nothing.

Thanks,

Dave
 
Try using MsgBox:

If vbYes = MsgBox("Do you want to print the report?", vbQuestion + _
vbYesNo, "Print Report?") Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.OpenReport stDocName, acNormal, , stLinkCriteria
End If
 
I have a Categories and Products form that after running some code I want it
to ask me if I want to print the Invoice or not,
i.e. DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70

DoCmd.OpenReport stDocName, acNormal, , stLinkCriteria

If I answer yes, it goes ahead and runs above code, else does nothing.

Thanks,

Dave

I'd suggest using more uptodate code: the form wizards unaccountably
use this very old, all but obsolete syntax, and there are better ways!
Something like:

Dim iAns As Integer
iAns = MsgBox("Do you want to print the invoice?", vbYesNo)
If iAns = vbYes Then
' Save the record
If Me.Dirty = True Then Me.Dirty = False
' open the Report
DoCmd.OpenReport stDocName, acNormal, , stLinkCriteria
End If
 
Back
Top