Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Subforms using conditions

Status
Not open for further replies.

rjf3123

Technical User
Sep 29, 2003
9
US
I have a form with a field that can contain one of three values; 0%, 40% or 50%. I have three subforms (one for each of the possible values). Is it possible to display the appropriate subform based on the value of this field?

TIA -
R. Fisher
 
Here is a way I did it using an option box. The concept should work as well with a text box. Option boxes store integer values for each selection (1, 2, 3, or 4 in this example).

Good luck.

Shane
Code:
Private Sub OptionBox1_AfterUpdate()
Select Case OptionBox1
    Case 1
        Me!SubformName.SourceObject = "Form1"
    Case 2
        Me!SubformName.SourceObject = "Form2"
    Case 3
        Me!SubformName.SourceObject = "Form3"
    Case 4
        Me!SubformName.SourceObject = "Form4"
End Select
End Sub
 

You should be able to switch the Source Object of the subform using VBA.

Me.[Subform Control Name].SourceObject = "Name of Form"

Where [Subform Control Name] is the name
of the subform control in your main form, and "Name of Form" is the name of the form you wish to use as the Subform.

Member,
SAGA

(Society Against Geek Acronyms)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top