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!

unloading a form 1

Status
Not open for further replies.

Newatprogramming

Technical User
Mar 5, 2002
30
0
0
US
I am trying to write some simple instructions. I want to close a form, but before the form closes I want another box to open verifing that I want to exit the form. If the user says YES form closes if says NO returns to the form. Any help?
 
What you want here is the Form_QueryUnload event which is called when the x is clicked. You'll see it has a Cancel parameter. If you set Cancel = True, the form won't unload.
So, if you had a message box that asked whether the form was to be unloaded, and if it wasn't Cancel was set true, you'd be there. Peter Meachem
peter @ accuflight.com

 
Newatprogramming - I see that you have started 10 threads, and have only said thank you once, and have yet to indicate that any post has been helpful.

Since you're fairly new to the forum, yet may not be aware that Tek-Tips is a forum by and between professionals, it is not a tech support site, and its a good practice to share as you can with other members of the forum and to show professional courtesy when warranted.

That being said, I suggest that you take a look at the Query_Unload event of the form. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
You can use the Form_QueryUnload Event

If the user says yes, set Cancel = 0, Else set Cancel = 1 and the form will stay open

Rob
 
Well maybe Cajun, all the anwers were most unhelpful and Newatprogramming was too polite to say so. Peter Meachem
peter @ accuflight.com

 
Perhaps petermeachem you are correct. Have you read the previous posts and responses? Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Here is the code!

Private Sub UnloadThisForm_Click
Dim lAnswer As Long

lAnswer= MsgBox("Are you sure you want to exit?", _ vbYesNo, "MyProject")

If lAnswer = vbYes Then
Unload Me
End If
End Sub

There it is. Hope this helps.
 
Was being amusing. A lot of people forget to say thankyou. Peter Meachem
peter @ accuflight.com

 
CajunCenturion

Your first reply in this thread has been most helpful - you may find it quoted by others (esp. me!) as and when appropriate.

Thank you. I have also starred your post
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top