Results 1 to 4 of 4

Thread: Canceling Form Unload ***Resolved***

Hybrid View

  1. #1
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Canceling Form Unload

    Well in your case you should use the QueryUnload event since you only want to hide the form if someone clicks the X button. But if someone is shuting down Windows or you want to end the application through code you want to unload the form so your application ends properly. You can only test why your form is being unloaded in the QueryUnload event.
    VB Code:
    1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    2.     If UnloadMode = vbFormControlMenu Then
    3.         'the X has been clicked or the user has pressed Alt+F4
    4.         Cancel = True
    5.         Me.Hide
    6.     End If
    7. End Sub

  2. #2

    Thread Starter
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Canceling Form Unload

    Joacim,
    Thanks again!!!!

    Mark
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width