Msgbox loop

G

Guest

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
 
D

Dirk Goldgar

StuJol said:
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

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 -----
 

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