Close App. with a MessageBox

A

AFSSkier

How can I do a close app. using DoCmd.Quit with a MSGBOX saying "Are you sure
you want to close Application?".
 
F

fredg

How can I do a close app. using DoCmd.Quit with a MSGBOX saying "Are you sure
you want to close Application?".

If MsgBox("Are you sure you want to close the Application",vbYesNo) =
vbYes then
DoCmd.Quit
End If
 
D

Douglas J Steele

fredg said:
If MsgBox("Are you sure you want to close the Application",vbYesNo) =
vbYes then
DoCmd.Quit
End If

In the event that you're trying to stop accidental shutdown of the
application, have a form that's always open (it needn't be visible). In that
form's Unload event, put:

If MsgBox("Are you sure you want to close the Application?",vbYesNo) <>
vbYes then
Cancel = True
End If
 
A

AFSSkier

This is the current Form Code Argument.

' Exit the application.
Case conCmdExitApplication
DoCmd.Quit

Is this how the new Argurment with the MsgBox should be?

' Exit the application.
Case conCmdExitApplication
If MsgBox("Are you sure you want to close the Application",vbYesNo) =
vbYes then
DoCmd.Quit
 
F

fredg

This is the current Form Code Argument.

' Exit the application.
Case conCmdExitApplication
DoCmd.Quit

Is this how the new Argurment with the MsgBox should be?

' Exit the application.
Case conCmdExitApplication
If MsgBox("Are you sure you want to close the Application",vbYesNo) =
vbYes then
DoCmd.Quit

Don't forget to add the End if after DoCmd.Quit.

Case conCmdExitApplication
If MsgBox("Are you sure you want to close the Application",vbYesNo) =
vbYes then
DoCmd.Quit
END IF
 
E

E-mail report using Lotus Notes rather t

Hi Douglas,

How do you make a form invisible when you open the application? I have a
form that opens as startup and I want to prevent users to accidently click
the application with the red (X). I have a button on the startup form to ask
user if they want to exit application. thanks.
 
D

Douglas J. Steele

You'll need to use the AutoExec macro.

You can either have it call a function, and have the function use the
DoCmd.OpenForm method (setting the window mode to acHidden), or you can have
the AutoExec function open your form (again, setting the window mode to
Hidden).

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"E-mail report using Lotus Notes rather t"
 
Top