Conditional Subforms?

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?
 
J

Jeanette Cunningham

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
 
F

Faraz A. Qureshi

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?


.
 
J

Jeanette Cunningham

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?


.
 

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