IsLoaded Function Looking at subforms

jsanders

If I Only had a Brain
Local time
Today, 00:47
Joined
Jun 2, 2005
Messages
1,910
Can anyone tell me the syntax for using the IsLoaded function to return the loaded status of a subform please.

Joe
 
Thanks Unc,

The reason I’m wanting to do this is, I have a drop down list attached to a field in a subform.

The query behind the drop down is filter (ordered by) a field in another subform.

The code works fine it requeries the drop down and everyones happy.

However it return an error message when you open the form.
“You entered an expression that has an invalid reference to the property form/Report”

Press OK and the code works perfectly well.

So I suspect the code is running before the main form has completely acquired the subform.

The code is attached to ‘On Current Event”

Both of these lines work the first one cause no error message, the second one does.

Me.Parent![Lot Options subform].Requery
Me.Parent![Lot Options subform].Form![OptionID].Requery

What do you think, kind of weird isn’t it?
 
Is there a way to force a form to load it populace in an ordered fashion?

In other words can you force a form to load its objects, in a certain order?
 
Last edited:
A subForm loads before the parent, but why would you Requery the Parent from the sub?
 
Actually that code refers to another subform, on the same form.

Off hand I can’t think of a reason to requery a main form from a subform, but there are many reasons to requery other subforms.

Anyway the subform with the code attached to is loading before the one it refers. So either I need some code that won’t cause an error or I need to force the order that the form loads the subforms.

I would really appreciate any input.
 
You could remove the Source object form the subform control. Ie It doesn;t contant a subform, then once the parent has loaded pass the name of the sub form you want to the control.

eg. Called form the parent form. Me.SubformControlName.SourceObject = "SubFormName".
 
but there are many reasons to requery other subforms.

Not in the CurrentEvent there isn't, your code is in the wrong place, put it in the AfterUpdate event
 
Maybe. But what if you’re just "scrolling" through the records?
Using the "On Current" event keeps all subordinate subforms in sync
Microsoft uses that event to connect subforms in their subform creation wizard.

Having said all that you may have a good point.

Since the subform requery (Me.Parent![Lot Options subform].Requery) doesn’t return an error on loading. It could be left on the “On current” event.

The code that requeries the combo box within the subform (Me.Parent![Lot Options subform].Form![OptionID].Requery) might actually work fine on the “on enter” event of the “Lot Option Subform” because you would not need the combo box requeried unless you were going to use it.

I’m going to try that, I’ll let you know if it works.

It’s interesting how discussing problems with colleagues brings things to light that might otherwise take days to fix.

Thanks Rich,
 
Last edited:
That's it. That combination of events did the trick.

Hope to have another discussion with you soon.

Thanks Again
 
I am, but that doesn’t synchronize the display.
Whenever you have more than one subform on a form and one of them is linked (using the child-parent) to the other one you must force the second one to requery programmatically.

Example:

Tables:
Customer
Orders
Order Details

Where Customer is linked to Orders and Orders is Linked to Order Details and the main form displays Customers.

First Subform (Orders subform)

Data:
Source Object…Orders Subform
Link Child Field…CustomerID (or something like that)
Link Master Field…CustomerID

This tell the form which fields to use to control the display.

However when you add the second subform you need to do some extra stuff.

This is what you need to make the “Order Details subform” work.

Source Object…Order Details Subform
Link Child Field…OrdersID
Link Master Field…[Orders subform].Form![OrdersID]

That forces the “Order Details subform” to display according the “Orders subform”

But that’s not enough. The “Order Details subform will NOT automatically requery when you scroll down the “Orders subform”. You must force it to requery.

You do that by adding this code to the Orders subform “On Current” event:
Me.Parent![Order Details subform].Requery
 
Dan_T said:
You could remove the Source object form the subform control. Ie It doesn;t contant a subform, then once the parent has loaded pass the name of the sub form you want to the control.

eg. Called form the parent form. Me.SubformControlName.SourceObject = "SubFormName".

Dan,
Thank you for the suggestion.
Sorry I didn't get back earlier I overlooked your post.
That might work, but fortunately for me, moving the code to the "exit" event did the trick.
 
No worries mate, it's a suggestion that can sit there for others to use if it appeals to them.
 

Users who are viewing this thread

Back
Top Bottom