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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Message Box Problem

Status
Not open for further replies.

Only1Abhi

Technical User
Jan 26, 2003
77
0
0
GB
Hi People.
What's wrong with this code?
When I press the button to exit the program, I want a message box to appear, which confirms this action.


Private Sub cmdExit_Click()

MsgBox("Are you sure you want to exit?", vbYesNo, "Exit The Program")

End Sub
 
Did you make sure the 'OnClick' event for the button is pointing to this sub? You also realize the button will not close the window with just a msgbox in the sub, right? You need DoCmd.Close (assuming this button is in the main window) as well, depending on the answer to your message box.
 
Try this:

Private Sub cmdExit_Click()

if MsgBox("Are you sure you want to exit?", vbYesNo, "Exit The Program") = vbYes then
application.quit
end if

End Sub
 
Only1Abhi,

here you go:

If MsgBox("Are you sure you want to exit?", vbYesNo, "Exit The Program") = vbYes Then
DoCmd.Close acForm, Me.Name
End If

Logicalman
 
thanks guys...

But I solved it using another way.

When I click the button, another form loads with Yes & No button.


That solved the problem.

Thanks anyway!

Kind Regards,
Abhi!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top