Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What's the difference between the two properties?
    Do Open events occur before Load events?
    Armstrong

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The On Open event of a form occurs almost immediately when a form is opened, before the records have been loaded into memory.
    The On Open event procedure has an argument Cancel that you can set to True if you want to abort the opening of the form. For example:

    Code:
    Private Sub Form_Open(Cancel As Integer)
      If Not CurrentProject.AllForms("frmOther").IsLoaded Then
    	Cancel = True
      End If
    End Sub
    The On Load event occurs later, when the records are being loaded into memory.
    The On Load event procedure has no arguments, so you can't cancel it.

    If you need to be able to cancel opening the report, use the On Open event.
    If you need to do something with records in the form, use the On Load event because the On Open event occurs too early for that.

  3. #3
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi HansV,
    First, thanks for your generosity to provide the complete VBA code.
    Nonetheless, I pray for more clarity from you.

    Questions:
    >The On Open event of a form occurs almost immediately when a form is opened,..
    For "almost immediately when," does it mean immediately before OR after when a form is being opened?
    Collaterally, does it also imply the properties (such as name of a control) are NOT available in the Open event?

    >The On Load event occurs later, when the records are being loaded into memory.
    Does it mean that the On Load event is occurring while the records are being loaded?

    Thanks.

    Armstrong

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    According to the Access help:
    The Open event occurs when a form is opened, but before the first record is displayed.
    The Load event occurs when a form is opened and its records are displayed.
    The Open event does not occur before the form is opened. That would be impossible.
    So the names of controls etc. are available in the Open event procedure.
    But the values of controls might not be available yet, since the Open event occurs before the records are being displayed.

Posting Permissions

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