Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform Source Object?

Status
Not open for further replies.

Xenos132

Technical User
Dec 12, 2004
43
CA
Is there a way to change my Subforms source object form a command button on my subform. What I an trying to do is have a welcome subform and when the user clinks on a link it just changes the subforms source object

 
You can use code to change the sourceobject:
Code:
Me.sfrmControlName.SourceObject = "sfrmMySubFormName"

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
That’s what I thought.. I have tried both.

Me.SubVisible.SourceObject = "frm_HVBServiceOrdersBilling"
Also
Me.sfVisible.SourceObject = "frm_HVBServiceOrdersBilling"

And I get a compile error …Method or Data Member not found.

On my main page I use this Code to change the subforms value

. Dim sfVisible As Control
' Set sub form control object variable
Set sfVisible = SubVisible
sfVisible.SourceObject = "frm_Welcome"

I just cant change it while on the subform.

 
Are you attempting to change the source object of a subform control that has the focus? You may need to set the focus outside the subform before doing this.

Also, if the code is running in the subform, you will need to reference the parent form in your code.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top