Dynamically Binding Different Subforms

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
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.
 
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]
 
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]
 
Back
Top