Changing Subform source?????? (1 Viewer)

N1ck9141

Registered User.
Local time
Today, 13:56
Joined
Aug 21, 2008
Messages
72
I have a form say "form1" which contains a subform "form_sub" containing "form2"

can i put a text box with a button on "form1" that will change the contense of "form_sub" to what ever is in the textbox, e.g. "form2" or 3 or 4 etc...
 

SOS

Registered Lunatic
Local time
Today, 05:56
Joined
Aug 27, 2008
Messages
3,517
Yes, you could do this:

Code:
Me.YourSubformCONTAINERnameHere.SourceObject = Me.TextBoxNameHere

But you would have to include error handling so in case someone had a wrong value and it couldn't set it to a non-existing subform it wouldn't barf.
 

N1ck9141

Registered User.
Local time
Today, 13:56
Joined
Aug 21, 2008
Messages
72
Yes, you could do this:

Code:
Me.YourSubformCONTAINERnameHere.SourceObject = Me.TextBoxNameHere

But you would have to include error handling so in case someone had a wrong value and it couldn't set it to a non-existing subform it wouldn't barf.


Thank you but where abouts would i place this code in the main form design or the subform design???

also what do u mean by container name the main form name???
 

SOS

Registered Lunatic
Local time
Today, 05:56
Joined
Aug 27, 2008
Messages
3,517
Thank you but where abouts would i place this code in the main form design or the subform design???
You can choose when you need it so it is highly dependent upon what you are trying to accomplish.

also what do u mean by container name the main form name???
The Subform CONTAINER is the control on the main form that houses the subform. It may be named the same as the subform or it may not so in referring to things you need to refer to the container name instead of the subform name as Access wants to know the container name.

You can also read about subforms here and here.
 

N1ck9141

Registered User.
Local time
Today, 13:56
Joined
Aug 21, 2008
Messages
72
Thank you for all ya help its now working a treat...
 

SOS

Registered Lunatic
Local time
Today, 05:56
Joined
Aug 27, 2008
Messages
3,517
Glad we could help.
 

Users who are viewing this thread

Top Bottom