dynamic sub-form

depending on the value of a field [CodeDoc] on a main form, I want to present a specific (and different on each case) sub-form, using different master/child fields. Ideally, some properties eg. Height and Width should also be dynamically set.
How do I do it?
João serras-pereiraAsked:
Who is Participating?
 
Dale FyeConnect With a Mentor Commented:
You would use the Form_Current event, something like:

Private Sub Form_Current

    Select Case me.txt_CodeDoc
        Case "A"
            me.subformcontrolname.SourceObject = "frm_subformA"
            me.subformcontrolname.LinkMasterFields = "FieldA"
            me.subformcontrolname.LinkChildFields = "FieldA"
        Case "B"
            me.subformcontrolname.SourceObject = "frm_subformB"
            me.subformcontrolname.LinkMasterFields = "FieldB"
            me.subformcontrolname.LinkChildFields = "FieldB"
       Case Else
            me.subformcontrolname.SourceObject = "frm_subformElse"
            me.subformcontrolname.LinkMasterFields = "FieldID"
            me.subformcontrolname.LinkChildFields = "FieldID"
   End Select

End Sub

You could insert other lines in here to change the width and height of the subform if you wanted to.
0
 
als315Commented:
Yf you have fixed set of variants, you can create many subforms on same place and make visible only one, depending from your choice.
0
 
João serras-pereiraAuthor Commented:
Hi
What is a fixed set of variants? shall I define a number of forms and then a placeholder and then "show/hide"?
0
 
João serras-pereiraAuthor Commented:
gee thanks!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.