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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform Fields (show/hide) Based On Main Form Rb, Office 2003

Status
Not open for further replies.

jimjaix

MIS
Jan 14, 2011
17
US
Hi,

I have two radio buttons that's driven the form to show / hide certain fields. The main form also has 4 subforms, I want the subforms to hide/show fields based on the radio button on main form, how do I make it work? I am very new to coding. Thanks

Private Sub frameSelect_Dept_Click()
Select Case Me.Department.Value
Case 1
Me.language_child.Visible = True
Me.Occupation.Visible = False
Me.Cbomaritalstatus.Visible = False
Me.ChildLabel.Visible = True
Me.language_parent.Visible = True
Case 2
Me.Occupation.Visible = True
Me.Cbomaritalstatus.Visible = True
Me.ChildLabel.Visible = False
Me.language_parent.Visible = False
End Select
End Sub
 
How are ya jimjaix, and welcome to [blue]Tek-Tips![/blue]

Example:
Code:
[blue]Case 1
   Me!ControlName.Visible = True
   [subformName].form!ControlName = False[/blue]
Its all in how you reference the controls. See: Refer to Form and Subform properties and controls

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Omg it works, thank you so much I tried to play around with the code so many time and couldn't get it to work...


[tblHx_Current subform].Form!past_medications.Visible = False

This is what I used.
 
jimjaix . . .

A word of caution in your naming convention ...

You need to get away from long names. Your naming convention shou make it easy for you to read. You'll find this out when you write a lengthy piece of code. You'll find with long names that you spend alot of time deciphering ... instead of reading. As an example:
[blue][tblCurHX].form!PastMeds.Visible = False[/blue] is easier to read than [blue][tblHx_Current subform].Form!past_medications.Visible = False[/blue].

I hope you get the point ...

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Also you have what appears to be a form named
tblCurHX
That tells me the form and likely the table have the same name. That is real confusing. There are some traditional conventions
tbl tables
frm forms
rpt report
sFrm, subFrm, subforms
txtBx, txt textbox
etc

also if you name your fields correctly no requirement for the []. Only need them if it is a reserved word or there is spaces.
frmCurHX.form!PastMeds.Visible = False
but
[frmCur Hx].form
 
Thank you all for the replies, indeed my name convention is bad. I will update my name convention.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top