newbyvba
Technical User
- Feb 22, 2012
- 11
I’m popping a bit of code behind a combo box called comboobjective on a form. If the user chooses certain objectives numbers, I want one text box to become visible, but if they pick any one of another list of values, then the other text becomes visible.
The IF does it (as I’ve put below) but I’m sure there must be a better way to achieve this. I’ve been looking at Case but not really sure… I’ve still a lot to learn. Can you point met in the right direction please?
Private Sub Comboobjective_AfterUpdate()
'tests drop down list for values and makes the appropriate object visible
If Me.Comboobjective = 9 Or Me.Comboobjective = 10 Then
MsgBox ("Please select the TFC check box and enter a TFC reason.")
If Me.Comboobjective = 1 Or Me.Comboobjective = 2 Or Me.Comboobjective = 3 Or Me.Comboobjective = 5 Or Me.Comboobjective = 8 Then
Me.term_text.Visible = True
Else
If Me.Comboobjective = 4 Or Me.Comboobjective = 6 Or Me.Comboobjective = 7 Or Me.Comboobjective = 9 Or Me.Comboobjective - 10 Then
Me.Retirement_Age.Visible = True
End If
End If
End If
End Sub
The IF does it (as I’ve put below) but I’m sure there must be a better way to achieve this. I’ve been looking at Case but not really sure… I’ve still a lot to learn. Can you point met in the right direction please?
Private Sub Comboobjective_AfterUpdate()
'tests drop down list for values and makes the appropriate object visible
If Me.Comboobjective = 9 Or Me.Comboobjective = 10 Then
MsgBox ("Please select the TFC check box and enter a TFC reason.")
If Me.Comboobjective = 1 Or Me.Comboobjective = 2 Or Me.Comboobjective = 3 Or Me.Comboobjective = 5 Or Me.Comboobjective = 8 Then
Me.term_text.Visible = True
Else
If Me.Comboobjective = 4 Or Me.Comboobjective = 6 Or Me.Comboobjective = 7 Or Me.Comboobjective = 9 Or Me.Comboobjective - 10 Then
Me.Retirement_Age.Visible = True
End If
End If
End If
End Sub