Hi Folks,
I got a form that has quite a few areas where I am trying to make certain fields visible or invisible contingent/based upon the user selection in other fields. For instance, if a user selects a specific item from a combo box, the relevant and associated fields with that answer would be shown and the non-relevant fields would be hidden.
Here is the interesting thing: I am able to successfully use the code below and it successfully hides or shows fields based on whatever is updated in the combo box:
Private Sub growingup_afterupdate()
If Me.GrowingUp = "Two Parent Household" Then
Me.Check199.Visible = True
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
ElseIf Me.GrowingUp = "Single Parent Household" Then
Me.Check199.Visible = False
Me.Combo203.Visible = True
Me.Text210.Visible = False
Me.Check204.Visible = True
Me.Label454.Visible = True
ElseIf Me.GrowingUp = "Grandparent" Then
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
ElseIf Me.GrowingUp = "Other" Then
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = True
Me.Check204.Visible = False
Me.Label454.Visible = True
Else
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
End If
End Sub
However, if I use this same code on the form load, it will not work!
Private Sub Form_Load()
If Me.GrowingUp = "Two Parent Household" Then
Me.Check199.Visible = True
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
ElseIf Me.GrowingUp = "Single Parent Household" Then
Me.Check199.Visible = False
Me.Combo203.Visible = True
Me.Text210.Visible = False
Me.Check204.Visible = True
Me.Label454.Visible = True
ElseIf Me.GrowingUp = "Grandparent" Then
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
ElseIf Me.GrowingUp = "Other" Then
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = True
Me.Check204.Visible = False
Me.Label454.Visible = True
Else
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
End If
End Sub
I am not sure why the code works perfectly via the afterupdate but the exact same code fails to work via the form_Load ... the reason I need both to work is because there is a browse records and add new record feature in the form and therefore when the form is first opened it should show/hide whatever it needs to based on the combo box selection -AND- should show/hide whatever is needed based on if a user updates the combo box (the later functioning works fine)?
Any ideas would be greatly appreciated ... thanks,
Joe
I got a form that has quite a few areas where I am trying to make certain fields visible or invisible contingent/based upon the user selection in other fields. For instance, if a user selects a specific item from a combo box, the relevant and associated fields with that answer would be shown and the non-relevant fields would be hidden.
Here is the interesting thing: I am able to successfully use the code below and it successfully hides or shows fields based on whatever is updated in the combo box:
Private Sub growingup_afterupdate()
If Me.GrowingUp = "Two Parent Household" Then
Me.Check199.Visible = True
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
ElseIf Me.GrowingUp = "Single Parent Household" Then
Me.Check199.Visible = False
Me.Combo203.Visible = True
Me.Text210.Visible = False
Me.Check204.Visible = True
Me.Label454.Visible = True
ElseIf Me.GrowingUp = "Grandparent" Then
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
ElseIf Me.GrowingUp = "Other" Then
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = True
Me.Check204.Visible = False
Me.Label454.Visible = True
Else
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
End If
End Sub
However, if I use this same code on the form load, it will not work!
Private Sub Form_Load()
If Me.GrowingUp = "Two Parent Household" Then
Me.Check199.Visible = True
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
ElseIf Me.GrowingUp = "Single Parent Household" Then
Me.Check199.Visible = False
Me.Combo203.Visible = True
Me.Text210.Visible = False
Me.Check204.Visible = True
Me.Label454.Visible = True
ElseIf Me.GrowingUp = "Grandparent" Then
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
ElseIf Me.GrowingUp = "Other" Then
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = True
Me.Check204.Visible = False
Me.Label454.Visible = True
Else
Me.Check199.Visible = False
Me.Combo203.Visible = False
Me.Text210.Visible = False
Me.Check204.Visible = False
Me.Label454.Visible = False
End If
End Sub
I am not sure why the code works perfectly via the afterupdate but the exact same code fails to work via the form_Load ... the reason I need both to work is because there is a browse records and add new record feature in the form and therefore when the form is first opened it should show/hide whatever it needs to based on the combo box selection -AND- should show/hide whatever is needed based on if a user updates the combo box (the later functioning works fine)?
Any ideas would be greatly appreciated ... thanks,
Joe