Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / February 2004

Tip: Looking for answers? Try searching our database.

vbYesNo not working with DoCmd

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bart - 18 Feb 2004 20:56 GMT
I am calling the following procedure in a module to print
a report and save it but it always runs the DoCmd even if
the user chooses vbNo.  Any suggestions?

Public Function printoptions()
'This functions provides the user with the option to print
and save the report

   MsgBox "Do you want to print the letter?", vbYesNo
       If vbYes Then
           DoCmd.PrintOut acPrintAll
       End If

   MsgBox "Do you want to save the letter?", vbYesNo
       If vbYes Then
           DoCmd.OutputTo acOutputReport, , acFormatRTF
       Else
           DoCmd.Close
       End If

End Function

Thanks for your help.

Bart
Duane Hookom - 19 Feb 2004 01:39 GMT
If you want to return a value with MsgBox, use the function rather than the
command.
Select Case MsgBox("Do you want to print the letter?", vbYesNo+
vbQuestion,"Print Letter")
   Case vbYes
       'your code
   Case vbNo
       'Your code
End Select

Signature

Duane Hookom
MS Access MVP

> I am calling the following procedure in a module to print
> a report and save it but it always runs the DoCmd even if
[quoted text clipped - 21 lines]
>
> Bart
John Nurick - 19 Feb 2004 07:30 GMT
Hi Bart,

vbYes has the value 6 and is therefore always true. You need to use
MsgBox as a function, e.g. like this:

    If MsgBox("Do you want to print the letter?", _
     vbQuery + vbYesNo) = vbYes Then
       DoCmd.Printout......

>I am calling the following procedure in a module to print
>a report and save it but it always runs the DoCmd even if
[quoted text clipped - 21 lines]
>
>Bart

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.