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

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
 
K

Ken Snell

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
 
J

John Vinson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top