Subforms-within-form references

EPD Hater

Registered User.
Local time
Today, 09:38
Joined
Mar 30, 2003
Messages
50
I have two subforms displayed at the same time within one parent form (they are unbound). In both subforms, I have drop-down combo boxes to change the record source of the respective form (through VBA).

What I would like to do is when an item in the combo box in any of the subforms is selected (changing the record source), the record source in the other subform changes as well. I don't think I can refer to a subform directly from another subform. Is there any possible way to pull this off?

I have thought of putting the controls in the parent form to control the record sources of the unbound child subforms. Would that be the best thing to do instead?
 
Maybe something like this will work:

To refer to the other subform from the subform with the combo box:

Code:
Forms("M_F_N")("N_O_T_O_S_C").Form.RecordSource = whatever

M_F_N should be replace by the name of your Main_Form

N_O_T_O_S_C should be replaced the the Name_Of_The_Other_Subform_Control, i.e. the name of the box thing on the Main_Form in which the other subform appears.

The syntax may seem a bit off, but it works when you get the names right.

A slightly more logical looking alternative is:

Code:
Forms("M_F_N").Controls("N_O_T_O_S_C").Form.RecordSource = whatever
 
Thank you for your clear and concise answer. It has helped me greatly and I can now use and share this technique in the future!
 
Forms and subforms relations

Saw your post and I am running into the same issues.... i.e., I have a form and subforms that are unbound. Think I'm suffering from brain-block, though... would you mind sharing your VBA code on how you coordinate the data from the form to the subforms and vice-versa?

Thank you for your time...look forward to hearing from you. (Let me know if you want my e-mail address.)
 
Actually, I'm not coordinating any data between the form and the sub-forms, which is why I have them unbound. I am using the parent form to hold the two sub-forms (two record sources) so that they can be displayed side-by-side.
 
Thanks for your reply.... I'm now trying a different tack - a form with tabs on it instead. Think it has possibilities of being easier to read for the users (too much on one form, and their eyes / brain start wandering in multiple directions).

Thanks again!
 

Users who are viewing this thread

Back
Top Bottom