473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Bypass the unload event if the Exit button is clicked?

If the user accidentally clicks the X close button I'm using the
following code in the form unload event to stop them from accidentally
quitting Access.

Private Sub Form_Unload(Cancel As Integer)
Select Case MsgBox("Are you sure you want to exit?", vbYesNo)
Case Is = vbYes
Exit Sub
Case Is = vbNo
Cancel = True
End Select
End Sub

However if they use the EXIT button on the form I would like Access to
Quit without stopping the user and asking them if they want to exit
access.

Is it possible to bypass the unload event if the Exit button is clicked?

Apr 10 '06 #1
2 5741
when your exit button is clicked, change its caption from Exit to
Exiting
then in your unload event, bypass your current prompt if caption =
Exiting

Apr 10 '06 #2
js*****@bright.net wrote:
If the user accidentally clicks the X close button I'm using the
following code in the form unload event to stop them from accidentally
quitting Access.

Private Sub Form_Unload(Cancel As Integer)
Select Case MsgBox("Are you sure you want to exit?", vbYesNo)
Case Is = vbYes
Exit Sub
Case Is = vbNo
Cancel = True
End Select
End Sub

However if they use the EXIT button on the form I would like Access to
Quit without stopping the user and asking them if they want to exit
access.


Untried, but what about dimming a boolean at form level:

booOkToLeave as Boolean

Set it to false in the form on open event.

enclose your procedure above in:
Private Sub Form_Unload(Cancel As Integer)
If booOkToLeave = False then

end if
End Sub

Then, on your exit button, include:

booOkToLeave = True
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Apr 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Harry J. Smith | last post by:
I have written a Visual Basic program that does a long calculation and writes the results to disk as it runs. If I click the Close button the window closes but the program keeps running. How can I...
1
by: hal | last post by:
I have an application that includes an activex component that consumes resources that must be released when the a page is unloaded. Toward this end I subscribe to the unload event of the body...
1
by: Hal | last post by:
My most sincere gratitude to anyone who can help me work around this! I have work that needs to be done in javascript on the client whenever a page is unloaded. To this end, I subscribe to...
0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
4
by: Tom Vukovich | last post by:
Hi All, I have an application that I am porting from VB6 to VBNet and in vb6 i can detect the unloadMode. DotNet doesn't support this but I need the functionality. I understand the code should be in...
3
by: lesperancer | last post by:
I've got application A, with a hidden form, whose unload event is cancelled unless you use an 'exit' button (so I can do special processing) this works fine when using just application A and it...
3
by: rdemyan via AccessMonster.com | last post by:
Sometimes users (including myself) accidentally click on the application close icon in the application menu bar when they meant to just click on the 'X' for the form. Of course the app closes and...
11
by: Stevo | last post by:
I've been using the unload event for a long time. I have this code, which I've abstracted and made into a stripped down simple test case below, and it works fine on the major browsers (IE5+,...
5
by: =?Utf-8?B?U3RldmVuIFRhbmc=?= | last post by:
It seems that one page XBAP whose Unloaded event never get called, I need put some clearing stuff (I.G stop dispatcher time) when user close browser, it unload event doesn't work, where shall I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.