Avatar of Joy Gomez
Joy Gomez
 asked on

Load subforms on button click

Hello,

I have a Main form and 3 subforms.  Each of the 3 sub forms has more sub forms.  When I initially open the Main form, I do not want to load any of the 3 sub forms or their subforms.  I also have 3 buttons inside the Main form.  On the click of these buttons, I want to open the corresponding subforms and its subforms.

Thanks much in advance for your help
Joy
Microsoft Access

Avatar of undefined
Last Comment
Joy Gomez

8/22/2022 - Mon
Gustav Brock

This is done by setting the RecordSource of the subform(s) when you click that button:


Dim f As Form
Set f = <the subform in question>
f.RecordSource = Name of query or an SQL sentence.

Open in new window

When done, the subform will update at once.

ASKER CERTIFIED SOLUTION
Dale Fye

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Joy Gomez

ASKER
Hi Dale,

Thanks for the note...

Are you saying that when I load the main form, I should by default make the subforms visibility=false... then on button click make the subform visibility=true? Does that have the same effect as loading a form?  The reason I am doing this, is because I have so many subforms, that it takes forever to load the main form, and I am trying to reduce this time.

Thanks
Joy
SOLUTION
PatHartman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Dale Fye

I agree with Pat, although I think she meant the subform controls  "SourceObject" should be blank, not "ControlSource"


Dale

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Joy Gomez

ASKER
Worked!  Thanks All!