Dynamically Binding Different Subforms

N

news.microsoft.com

I'm not sure if this is possible but can I bind different subforms
dynamically depending on record type from the main form?
I have 5 different record types and each has different look to it.
I can have 5 different subforms and play with Visible property.
I'm thinking of having 1 subform and bind the subforms on the fly.
Doable? Sample code if you have it. TIA.
 
J

John Vinson

I'm not sure if this is possible but can I bind different subforms
dynamically depending on record type from the main form?
I have 5 different record types and each has different look to it.
I can have 5 different subforms and play with Visible property.
I'm thinking of having 1 subform and bind the subforms on the fly.
Doable? Sample code if you have it. TIA.

Yes, and often useful. Simply set the Subform control's SourceObject
property to the name of the desired subform:

Dim strFormName As String
Select Case <whatever>
Case 1
strFormName = "subThisSubform"
Case 2
strFormName = "subThatSubform"
...
End Select
Me!subGenericSubform.SourceObject = strFormName

John W. Vinson[MVP]
 
J

John Vinson

How about database binding? Master and Child fields. TIA.

Same deal. When I've had to do this, they've been the same links for
all possible subforms on a mainform, but there's no difficulty in
changing the Subform control's Master or Child Link Properties, just
as you would change the SourceObject property.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top