Results 1 to 3 of 3

Thread: Difference between Unload and Query Unload Events?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    Hyderabad,India
    Posts
    131

    Difference between Unload and Query Unload Events?

    What is the difference between the Query Unload and Unload events of the form?
    Regards,
    Phani

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    QueryUnloadOccurs before a form or application closes. When an MDIForm object closes, the QueryUnload event occurs first for the MDI form and then in all MDI child forms. If no form cancels the QueryUnload event, the Unload event occurs first in all other forms and then in an MDI form. When a child form or a Form object closes, the QueryUnload event in that form occurs before the form's Unload event.

    This event is typically used to make sure there are no unfinished tasks in the forms included in an application before that application closes. For example, if a user has not yet saved some new data in any form, your application can prompt the user to save the data.

    When an application closes, you can use either the QueryUnload or Unload event procedure to set the Cancel property to True, stopping the closing process. However, the QueryUnload event occurs in all forms before any are unloaded, and the Unload event occurs as each form is unloaded.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The QueryUnload event has an argument called UnloadMode with which you can determent why a form is unloading.
    Here's the values copied from MSDN Library
    vbFormControlMenu 0 The user chose the Close command from the Control menu on the form.
    vbFormCode 1 The Unload statement is invoked from code.
    vbAppWindows 2 The current Microsoft Windows operating environment session is ending.
    vbAppTaskManager 3 The Microsoft Windows Task Manager is closing the application.
    vbFormMDIForm 4 An MDI child form is closing because the MDI form is closing.
    vbFormOwner 5 A form is closing because its owner is closing.
    Best regards

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