Conditional Subforms?

  • Thread starter Thread starter Faraz A. Qureshi
  • Start date Start date
F

Faraz A. Qureshi

I have three different styles of subforms based on a single table.
Can I have all the three subforms be inserted in a major one but only ONE
being displayed, depending upon the type of entry selected in the major form?
 
Yes, you just set the Source Object of the subform control.

Me.[NameOfSubformControl].SourceObject = "frmSubform1"

The above code puts frmSubform1 as the subform into the subform control.

To change to another subform,
Me.[NameOfSubformControl].SourceObject = "frmNextSubform"


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Thanx Jeanette for your prompt response. However, how to insert an IF type
condition/code to control/change subform based upon the main form's entry?
--
Thanx & Best Regards,

Faraz!


Jeanette Cunningham said:
Yes, you just set the Source Object of the subform control.

Me.[NameOfSubformControl].SourceObject = "frmSubform1"

The above code puts frmSubform1 as the subform into the subform control.

To change to another subform,
Me.[NameOfSubformControl].SourceObject = "frmNextSubform"


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Faraz A. Qureshi said:
I have three different styles of subforms based on a single table.
Can I have all the three subforms be inserted in a major one but only ONE
being displayed, depending upon the type of entry selected in the major
form?


.
 
You could use a combobox or an option group.
For a combo, something like this code in the after update event for the
combo.
----------------------
Dim strTxt As String

If Me.NameOfCombo = 1 Then
strTxt = "frmSubform1"
ElseIf Me.NameOfCombo = 2 Then
strTxt = "frmNextSubform"
Else
strTxt = "frmThirdSubform"
End If
Me.[NameOfSubformControl].SourceObject = strTxt
---------------------------------

Note: replace the names of objects with the names you are using on your
form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Faraz A. Qureshi said:
Thanx Jeanette for your prompt response. However, how to insert an IF type
condition/code to control/change subform based upon the main form's entry?
--
Thanx & Best Regards,

Faraz!


Jeanette Cunningham said:
Yes, you just set the Source Object of the subform control.

Me.[NameOfSubformControl].SourceObject = "frmSubform1"

The above code puts frmSubform1 as the subform into the subform control.

To change to another subform,
Me.[NameOfSubformControl].SourceObject = "frmNextSubform"


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Faraz A. Qureshi said:
I have three different styles of subforms based on a single table.
Can I have all the three subforms be inserted in a major one but only
ONE
being displayed, depending upon the type of entry selected in the major
form?


.
 
Back
Top