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 / Modules / DAO / VBA / September 2005

Tip: Looking for answers? Try searching our database.

Msgbox loop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
StuJol - 08 Sep 2005 22:39 GMT
i have a print command on one of my forms. When you click the print button, a
quote is printed. A msgbox appears asking did the quote print. if the user
select yes then certain controls are adjusted. If user clicks no nothing
happens. Here is my code. When the user clicks no i want the code to print
the quote again and then display the same msgbox. i know i need to use the
loop statement but ive had no success. Can anyone help??

Private Sub PrintQuoteReport_Click()

'Print Quote From Work Order Form.
   
   Dim stDocName As String

   stDocName = "New Quote Report"
   DoCmd.OpenReport stDocName, acNormal

'Display MsgBox To Confirm If Quote Has Been Printed.

   Dim Response6 As Byte
   Response6 = MsgBox("Has The Quote Printed?         ", vbYesNo +
vbQuestion, "Work Order's Database")
   If Response6 = vbYes Then
       
   'Once Quote Is Printed Disable All Controls On Quote Tab.
       
   Quote_Valid_For_Days.Enabled = False
   QuotePreparedByCombo.Enabled = False
   QuoteCreatedDate.ForeColor = 11053139
   Label284.ForeColor = 11053139
   Conditions.Enabled = False
   
   'Once Quote Is Printed,Status Is Changed To Quote Sent.

   Combo73.Value = "Quote Sent"

   'Creates Date In Date Printed Field When Quote Was Printed.

   QuoteCreatedDate.Value = Date

   'Change Status Date.

   StatusDate.Value = Now
   
   End If
   
End Sub
Dirk Goldgar - 09 Sep 2005 00:27 GMT
> i have a print command on one of my forms. When you click the print
> button, a quote is printed. A msgbox appears asking did the quote
[quoted text clipped - 43 lines]
>
> End Sub

I suggest you also leave the user an option to cancel the printing of
the quote if there's something wrong and there's no way this quote is
going to print any time soon.

How about something like this:

'----- start of revised code (excerpt) -----
   Dim stDocName As String
   Dim Response6 As Byte

   stDocName = "New Quote Report"

   Do
       DoCmd.OpenReport stDocName, acNormal

       'Display MsgBox To Confirm If Quote Has Been Printed.

       Response6 = MsgBox( _
           "Has The Quote Printed?", _
           vbYesNoCancel+vbQuestion, _
           "Work Order's Database")

   Loop While Response6 = vbNo

   ' At this point, Response6 may be vbYes or vbCancel.

   ' Did the quote print successfully?
   If Response6 = vbYes Then

       'Disable All Controls On Quote Tab.
       Quote_Valid_For_Days.Enabled = False
       QuotePreparedByCombo.Enabled = False
       QuoteCreatedDate.ForeColor = 11053139
       Label284.ForeColor = 11053139
       Conditions.Enabled = False

       'Change status to "Quote Sent".
       Combo73.Value = "Quote Sent"

       'Set  date for when quote was printed.
       QuoteCreatedDate.Value = Date

       'Change Status Date.
       StatusDate.Value = Now

   End If

'----- end of revised code -----

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
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.