OnCurrent - Subform

lcook1974

Registered User.
Local time
Today, 17:31
Joined
Dec 21, 2007
Messages
330
Hey Everyone!
Why can you NOT use the ONCURRENT function in an Unbound form, with an unbound subform?

I have form that is basically a dashboard look...it has a list box of donors that have expenses to them. When I click on the list box, I wanted the subform of the unbound form to change to the selected record, however that didnt' work...The error messege was something about the form not being open. But it was, it was just embedded in the unbound form.

so my work around with the same code was to "Open the form" in another window....and presto it worked fine.

Larry
 
Hey Everyone!
Why can you NOT use the ONCURRENT function in an Unbound form, with an unbound subform?
Subform or form, if it's unbound it will not respond to any Form events that has to do with data.
 
Also, Larry - just a little more info for you. Subforms, when they are on the parent form, are not counted as being open forms. They are actually part of a CONTROL which is on the parent and that control displays the subform. So, for almost everything your referencing has to use that control name instead of the subform name and add the .Form. part if you want to refer to something on the subform itself. It is true that there are some things you don't need to use the .Form. part with as it is a default but I use it whenever referencing the subform because it makes it more explicit and easier to follow (in my opinion).

So, as vbaInet has said - if the form is unbound then it won't have data driven events like On Current, After Update, Before Update, etc. Well, technically they are still there but they do not fire.

So, you can bind the form and then requery it for your results, or you can use code to set its recordsource and which controls are bound to the fields, if you want. Or you can simply not have the subform control's source object set until you are ready for it (leaving the subform bound to the table/query).

See here for a sample which shows how to load subforms as you become ready for them.
 

Users who are viewing this thread

Back
Top Bottom