Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Code execution when form opened as dialog (200sr1a)

    Why does code execution pass to the FormLoad sub if I open a form as dialog without a where clause, but waits for me to click in an enabled box on the form before starting to execute FormLoad if I open the form with a where clause in the DoCmd.openform statement.

    What can I do to change this behaviour?

    thanks

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Code execution when form opened as dialog (200sr1a)

    Code execution in which module? The code in the calling routine will pause until you close the form you opened as a dialog. I don't understand the rest of your explanation. You can't click anything on a form being loaded until after it loads, so I'm not sure which form you're referring to. Could you explain in more detail?
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Code execution when form opened as dialog (200sr1a)

    If code in form A includes this line:

    DoCmd.OpenForm "frmB", , , , , acDialog,flag

    then code execution passes immediately to the Form_Load event procedure of frmB. If however, the line reads

    DoCmd.OpenForm "frmB", , , "[SomeFieldInTableSourceOffrmB]=" & criterion, ,acDialog,flag

    then execution of the Form_Load event procedure of frmB does not begin until I click on an enabled control in frmB, at which time Form_Load then executes. Of course frmB is not loaded at the time these calls are made. I've also tried with and without the openargs and it makes no difference, only the Where clause causes this behaviour.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Code execution when form opened as dialog (200sr1a)

    I'm still <img src=/S/confused.gif border=0 alt=confused width=15 height=20>. When I do this with a couple of forms, they appear to behave exactly the same way whether or not I pass a WhereCondition. How are you trying to determine when the Load event occurs? I used to separate buttons on frmA to call frmB with and without a WhereCondition. I put a msgbox in the Form_Load event of my frmB and it pops up before the form becomes visible, just as I would expect. Is there something else going on that you haven't mentioned? Is there code in Form_Load that would affect this somehow?
    Charlotte

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code execution when form opened as dialog (200sr1a)

    According to the online help, the order of events when a form is opened, is:
    1. <LI>Open
      <LI>Load
      <LI>Resize
      <LI>Activate
      <LI>Current
    If you open a form without code in these events, each event occurs one time, in this order. Whether you open the form with or without a Where-condition doesn't make a difference (in my tests). But if you have code in one or more of these events, this may cause events to occur more than once. For instance, if you change the sort order of the form in the Load event, the Activate and Current events occurs twice. I don't see how this would cause your form to wait for a click, but still, I would check what code you have for these events.

Posting Permissions

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