Difference between Form_Open and Form_Load?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • deko

    Difference between Form_Open and Form_Load?

    Is there a difference between the Form_Open and Form_Load events? When
    should I use one rather than the other? I have several forms that require
    code to run when they open... or is it when they load?

    Thanks in advance.


  • Don Leverton

    #2
    Re: Difference between Form_Open and Form_Load?

    Hi Deko,

    Here's a partial quote from Access97 Help:
    ----------------------------------------------
    When you first open a form, the following events occur in this order:
    Open Þ Load Þ Resize Þ Activate Þ Current
    If you're trying to decide whether to use the Open or Load event for your
    macro or event procedure, one significant difference is that the Open event
    can be canceled, but the Load event can't. For example, if you're
    dynamically building a record source for a form in an event procedure for
    the form's Open event, you can cancel opening the form if there are no
    records to display.

    When you close a form, the following events occur in this order:
    Unload Þ Deactivate Þ Close
    ----------------------------------------------
    HTH,
    Don

    "deko" <deko@hotmail.c om> wrote in message
    news:0Q_hc.5$2w 4.2@newssvr27.n ews.prodigy.com ...[color=blue]
    > Is there a difference between the Form_Open and Form_Load events? When
    > should I use one rather than the other? I have several forms that require
    > code to run when they open... or is it when they load?
    >
    > Thanks in advance.
    >
    >[/color]


    Comment

    • Bradley

      #3
      Re: Difference between Form_Open and Form_Load?

      deko wrote:[color=blue]
      > Is there a difference between the Form_Open and Form_Load events?
      > When should I use one rather than the other? I have several forms
      > that require code to run when they open... or is it when they load?
      >
      > Thanks in advance.[/color]

      Have you tried reading the Help ? :P
      --
      regards,

      Bradley


      Comment

      • MacDermott

        #4
        Re: Difference between Form_Open and Form_Load?

        Another significant difference is that the Form_Load event occurs after the
        data has been loaded into the form.
        So if you want to do anything with the data, you need to wait until then.

        HTH
        - Turtle

        "deko" <deko@hotmail.c om> wrote in message
        news:0Q_hc.5$2w 4.2@newssvr27.n ews.prodigy.com ...[color=blue]
        > Is there a difference between the Form_Open and Form_Load events? When
        > should I use one rather than the other? I have several forms that require
        > code to run when they open... or is it when they load?
        >
        > Thanks in advance.
        >
        >[/color]


        Comment

        • Mark

          #5
          Re: Difference between Form_Open and Form_Load?

          Turtle,

          So is there a significant difference between the Load event and the Activate
          event. What determines which of these to use?

          Say the form moves from record 3 to record 4 and the Current event occurs. If
          the current event contains code to make one or more changes to data, are the
          changes made in record 3 or record 4?

          Thanks!

          Mark


          "MacDermott " <macdermott@nos pam.com> wrote in message
          news:f20ic.7127 $gH6.4857@newsr ead3.news.atl.e arthlink.net...[color=blue]
          > Another significant difference is that the Form_Load event occurs after the
          > data has been loaded into the form.
          > So if you want to do anything with the data, you need to wait until then.
          >
          > HTH
          > - Turtle
          >
          > "deko" <deko@hotmail.c om> wrote in message
          > news:0Q_hc.5$2w 4.2@newssvr27.n ews.prodigy.com ...[color=green]
          > > Is there a difference between the Form_Open and Form_Load events? When
          > > should I use one rather than the other? I have several forms that require
          > > code to run when they open... or is it when they load?
          > >
          > > Thanks in advance.
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Julia Baresch

            #6
            Re: Difference between Form_Open and Form_Load?

            I think the best way to understand this is to try it and see if it
            does what you want. Make a copy of your form and data source to play
            with, and see what happens when you put code in one event or the
            other. I think this is the fastest way to get a feel for it.

            Julia

            "Mark" <mmorrow@earthl ink.net> wrote in message news:<pp4ic.722 1$gH6.6200@news read3.news.atl. earthlink.net>. ..[color=blue]
            > Turtle,
            >
            > So is there a significant difference between the Load event and the Activate
            > event. What determines which of these to use?
            >
            > Say the form moves from record 3 to record 4 and the Current event occurs. If
            > the current event contains code to make one or more changes to data, are the
            > changes made in record 3 or record 4?
            >
            > Thanks!
            >
            > Mark
            >
            >
            > "MacDermott " <macdermott@nos pam.com> wrote in message
            > news:f20ic.7127 $gH6.4857@newsr ead3.news.atl.e arthlink.net...[color=green]
            > > Another significant difference is that the Form_Load event occurs after the
            > > data has been loaded into the form.
            > > So if you want to do anything with the data, you need to wait until then.
            > >
            > > HTH
            > > - Turtle
            > >
            > > "deko" <deko@hotmail.c om> wrote in message
            > > news:0Q_hc.5$2w 4.2@newssvr27.n ews.prodigy.com ...[color=darkred]
            > > > Is there a difference between the Form_Open and Form_Load events? When
            > > > should I use one rather than the other? I have several forms that require
            > > > code to run when they open... or is it when they load?
            > > >
            > > > Thanks in advance.
            > > >
            > > >[/color]
            > >
            > >[/color][/color]

            Comment

            • MacDermott

              #7
              Re: Difference between Form_Open and Form_Load?

              I would agree with Julia's suggestion on your second question.
              (BTW - it's usually a better idea to start a new thread if you want to
              bring up a new question.)

              As for Load and Activate, consider this scenario:
              Form1 has Button1 which runs code:
              DoCmd.OpenForm "Form2"
              Form2 has Button2 which runs code:
              DoCmd.OpenForm "Form3"
              you push Button1, see Form2
              Form2's Open, Load, and Activate events fire (among others)
              Now Push Button2.
              Form3 opens, and gets the focus.
              Close Form3
              Form2 gets the focus, causing its Activate event to fire again.
              Since it was already loaded, its Load event does not fire.
              Note: If you move to a different application (i.e. MS Word), instead of to
              a different Access form, the form's Activate event does not fire when you
              return to the Access application.

              HTH
              - Turtle

              "Mark" <mmorrow@earthl ink.net> wrote in message
              news:pp4ic.7221 $gH6.6200@newsr ead3.news.atl.e arthlink.net...[color=blue]
              > Turtle,
              >
              > So is there a significant difference between the Load event and the[/color]
              Activate[color=blue]
              > event. What determines which of these to use?
              >
              > Say the form moves from record 3 to record 4 and the Current event occurs.[/color]
              If[color=blue]
              > the current event contains code to make one or more changes to data, are[/color]
              the[color=blue]
              > changes made in record 3 or record 4?
              >
              > Thanks!
              >
              > Mark
              >
              >
              > "MacDermott " <macdermott@nos pam.com> wrote in message
              > news:f20ic.7127 $gH6.4857@newsr ead3.news.atl.e arthlink.net...[color=green]
              > > Another significant difference is that the Form_Load event occurs after[/color][/color]
              the[color=blue][color=green]
              > > data has been loaded into the form.
              > > So if you want to do anything with the data, you need to wait until[/color][/color]
              then.[color=blue][color=green]
              > >
              > > HTH
              > > - Turtle
              > >
              > > "deko" <deko@hotmail.c om> wrote in message
              > > news:0Q_hc.5$2w 4.2@newssvr27.n ews.prodigy.com ...[color=darkred]
              > > > Is there a difference between the Form_Open and Form_Load events?[/color][/color][/color]
              When[color=blue][color=green][color=darkred]
              > > > should I use one rather than the other? I have several forms that[/color][/color][/color]
              require[color=blue][color=green][color=darkred]
              > > > code to run when they open... or is it when they load?
              > > >
              > > > Thanks in advance.
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              Working...