Reaching Controls Properties in AllForms Collection?

geralf

Registered User.
Local time
Today, 22:25
Joined
Nov 15, 2002
Messages
212
I would like to set certain properties for forms in a db using VBA. I've been playung around with Forms and AllForms Collection without any desired results. Any help on getting to a db's controls in forms would be appreciated. Thanks in advance.
 
As you loop through the Forms Collection, you can Use the Form Object and loop through the Controls collection.
 
Hi Travis
Thanks for replying. I've already done that. Problem is that if a form contains subforms, only the mainform exists in the Forms collection. I do think I have to use the AllForms Collection, which has all the forms in a db. If a form aint loaded - I have to load it, and set the properties I want. I don't know how or if it's possible to get to the controls prperties through the AllForms Collection. Any suggestions?
 
Last edited:
A subform is a control of the Main Form. When you reach a sub form control you can set a variable = to it and then loop through the controls of the SubForm.

Be careful Access allows Sub Forms Three Deep.
 
Thanks Travis

I'm having trouble setting a variable (Dim MyVar As Form?) to the control on the Mainform that's the subform. I get a 'type missmatch error'. How would I set this variable?
Thanks for your help.

hth
Gerhard
 
Tried it without any luck. Got an 'Type missmatch error'. So I tried to Dim the variable as a control, and it worked to my surprice. So the way I see it - the mainform's subform control has the controls for the subform. So if there's a new subform control - then that one will contain the sub-sub form controls. I'm struggeling to make a sensible VBA code to do this. The scenario is this:

Check Forms Collection for open forms, if any - check the controls collection for the form. If a subform control is present - start a new search for a subform control.......... If I understand Travis correctly, the subforms can't be deeper than sub-sub-sub form in a main form. Any suggestions how to program this nicely?

Thanks for replying though.

hth
Gerhard
 

Users who are viewing this thread

Back
Top Bottom