Results 1 to 13 of 13
  1. #1
    Join Date
    Apr 2003
    Posts
    59

    Unanswered: Need to wait during code execution to allow subform to load

    My main form displays the total from a subform. I want to compare that total with another field in the main form in order to flag up when the user goes over budget or something.

    The problem is, the code runs before the total has updated on the main form, so the value in the total field is 0. How do I make the code wait?

    Thanks xx

    Forgot to say, I'm using Access 97
    Last edited by katerpillar; 06-06-07 at 08:28.

  2. #2
    Join Date
    Feb 2007
    Posts
    348
    I think/I hope the answer is me.repaint.

  3. #3
    Join Date
    Aug 2006
    Posts
    559
    Quote Originally Posted by katerpillar
    My main form displays the total from a subform. I want to compare that total with another field in the main form in order to flag up when the user goes over budget or something.

    The problem is, the code runs before the total has updated on the main form, so the value in the total field is 0. How do I make the code wait?

    Thanks xx

    Forgot to say, I'm using Access 97

    Where are you using the 'compare' portion of your db? You can probably set it on the "on close" or "after update" on the subform to compare the data from that form to the data in the main form.

  4. #4
    Join Date
    Apr 2003
    Posts
    59
    Quote Originally Posted by Grafixx01
    Where are you using the 'compare' portion of your db? You can probably set it on the "on close" or "after update" on the subform to compare the data from that form to the data in the main form.
    That's an idea... but I'm not sure which event I need. The subform changes because I change its recordsource based on a selected date in the main form. (The compare happens within the same function as that.) What kind of events does that trigger for the subform? I tried OnCurrent but that's still too early, the total isn't calculated yet.

  5. #5
    Join Date
    Feb 2007
    Posts
    348
    after update?

  6. #6
    Join Date
    Aug 2006
    Posts
    559
    I've found it's kind of like 'trial and error'. Try it in the OnClose, OnUpdate, BeforeUpdate, AfterUpdate.

    I think that the AfterUpdate, OnUpdate and OnClose will be your best bet though.

  7. #7
    Join Date
    Apr 2003
    Posts
    59
    Quote Originally Posted by starkmann
    I think/I hope the answer is me.repaint.
    That doesn't work, but thanks anyway x

  8. #8
    Join Date
    Feb 2007
    Posts
    348
    Quote Originally Posted by katerpillar
    That doesn't work, but thanks anyway x
    If you're calling it from the subform, you'd have to set focus first.

  9. #9
    Join Date
    Apr 2003
    Posts
    59
    Quote Originally Posted by Grafixx01
    I've found it's kind of like 'trial and error'. Try it in the OnClose, OnUpdate, BeforeUpdate, AfterUpdate.

    I think that the AfterUpdate, OnUpdate and OnClose will be your best bet though.
    It doesn't close or update as far as I can tell.
    Am I being really stupid here?

  10. #10
    Join Date
    Aug 2006
    Posts
    559
    Try uploading your db in a zip and we'll look at it.

  11. #11
    Join Date
    Apr 2003
    Posts
    59
    Quote Originally Posted by starkmann
    If you're calling it from the subform, you'd have to set focus first.
    No, I'm calling it from the main form. I tried requerying refreshing and repainting everything in sight!

  12. #12
    Join Date
    Apr 2003
    Posts
    59
    Quote Originally Posted by Grafixx01
    Try uploading your db in a zip and we'll look at it.
    Thanks for your help, but by the time I've taken out the confidential stuff it's not worth it, it was just a tweak. Thanks a lot both of you. x

  13. #13
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    How are you calculating the total from the Subform? I did something similar to this (kind of like an order screen, the subform was the line item detail, and the main form had the totals). From what I remember I put code in the main form and the subform. The main form used a Recordsetclone of the subform to do the calculation and I believe I would have done it in the OnCurrent event. Any more details?

Posting Permissions

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