Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on YesNo MsgBox 1

Status
Not open for further replies.

PPJOSEPH

IS-IT--Management
Apr 2, 2003
82
US
Hi:
I've created 2 vbYesNo MsgBox
one to save the input and second to print the input.

If I chose not to save the input I want to form "frmOpenAsgmt" to automatically close when I click the No button, how can I get it to work.

Any help is greatly appreciated.

Below is the code where I get stuck:

Private Sub cmdExit_Click()
On Error Resume Next


If MsgBox("Do you wish to save your input? (Selecting No will cancel any additions or changes made.)", vbYesNo) = vbYes Then
vrSavePrompt = True


If MsgBox("Do you wish to print this form?", vbYesNo) = vbYes Then

Dim stDocName As String
Dim MyForm As Form

stDocName = "frmOpenAsgmt"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
End If
DoCmd.Close
End If
Exit_cmdExit_Click:
Exit Sub
 
Your "DoCmd.close" is inside the first if check.

End If
DoCmd.Close
End If
(should be here)

Therefore you would only get to that line of code if the first if check were true (i.e. the user selects yes)

You will need to put the docmd.close outside the first if check. Then when the first if check does not equal vbyes, you fall outside the if and the form closes.

 
Thank you so much for you quick reply. It worked great. Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top