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

Tweeking a Exit Button! 1

Status
Not open for further replies.

Joel27

Programmer
Mar 28, 2001
23
US
On my autoexec form I have a button on it that quits access or the database if you will. I use the following code to do so:

Private Sub quit1_Click()
On Error GoTo Err_quit1_Click

dim holder as string
holder = msgbox("Are You Sure You Want To Quit?",vbYesNo)
if vbYes then Docmd.Quit
Else
end If

Exit_quit1_Click:
Exit Sub

Err_quit1_Click:
MsgBox Err.Description
Resume Exit_quit1_Click

End Sub



What Am I doing wrong
Thanks Joel


 
if holder = vbYes then Docmd.Quit
Mike Rohde
rohdem@marshallengines.com
 
Hi Joel, Mike,
I'll elaborate a spec to Mikes solution and add:

Private Sub quit1_Click()
On Error GoTo Err_quit1_Click
If MsgBox("Are you sure you want to quit? ", vbYesNo + vbQuestion + vbDefaultButton1, "Quit application confirmation...") = vbNo Then Exit Sub
Application.Quit acQuitSaveAll

Exit_quit1_Click:
Exit Sub

Err_quit1_Click:
MsgBox Err.Description
Resume Exit_quit1_Click
End Sub

Two treats here 1: sneaky little method to center your text in your message box when you use an icon. Add about 16 spaces and everything will look right. 2: Application.Quit will knock out Access and the save all takes care of anything that's left open in the background and without warning. Extra treat.. no declared variable. Voila! ;-) Gord
ghubbell@total.net
 
Is there a way to edit the title bar on a message box?

I like the code you gave me, Gordon
very nice:)
Joel
 
Thanks Joel and yes just as you see in the example above. The "Quit application confirmation..." is where you can do this. This is really important in 2000: Even with a "Database title", It won't be picked up and your users would always get a title of "Microsoft Access." :) Gord
ghubbell@total.net
 
My guess is that in this line:

vbQuestion + vbDefaultButton1, "Quit application confirmation...") =

the "Quit application confirmation..." is the title bar on the message box --- so just edit that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top