I have "form_current" event in a subform of a main form. For some reason, it is firing more than once in the subform. Can't see why at all. Can anyone help? Thank you.
I can't tell you the reasons for it, only that it happens and it's gonna continue to happen. The current event of a subform seems to fire one extra time when it gets loaded (?and requeried?). You may be able to work around it with code that counts and only runs it once. Or by using another event.
Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
If a subform contains "many" records, each related to a main record in the main form, then the CURRENT event will fire for each one of them as soon as the subform is opened. I know it sounds bizarre, but it appears to be the way the ON_CURRENT event works in subforms.
Jim
Me? Ambivalent? Well, yes and no....
Another free Access forum:
I don't think that's correct. Try a simple test where you put some code in the current event of the sub form. I don't think it will happen once per record. In my tests it happens twice, except when I first open the main form, at which time it only happens once.
Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
Now that I've tested it with something real, Jeremy has it spot-on. Here's what happens:
When the main form is loaded, it attempts to grab the records needed to populate the subform. This, for some reason, fires off the SUBFORM's ON_CURRENT event, (BEFORE the main form's ON_CURRENT, BTW.)
This takes place even before the MAIN form is visible.
Once up and running, if a change is made to any of the records in the subform, the ON CURRENT event (and rightly so) fires for the new record.
So probably what you can do is TRAP the first event, and break out of it.
I stupidly tested it by incrementing, and lazily only used two child records..senior moment.
JMH
Me? Ambivalent? Well, yes and no....
Another free Access forum:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.