Link to home
Create AccountLog in
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
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

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
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Joy Gomez
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
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account

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


Dale

Worked!  Thanks All!