Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form_current firing multiple times in a subform. 1

Status
Not open for further replies.

bkatz

IS-IT--Management
Jun 16, 2002
7
US
Hello,

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.

Jeremy ==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

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:
More Access stuff at
 
Jim,

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.

Jeremy ==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Hmmmm.. I guess that's what happens when you only have TWO child records in your test population.. duhhhh me...

I'm not as multitasking as I used to be.. :)

Right you are. Have a celestical object..

J Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Heh. :^) ==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

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:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top