enabling controls based on previous control

  • Thread starter Thread starter Laura
  • Start date Start date
L

Laura

I need to have a form that works such that if the user
answers no to question one, they cannot answer question
two (the control becomes invisible).

I really can't seem to find an answer to this.

I've tried

If Me!questionone = "No" Then
Me!questiontwo.Enabled = False
Else
Me!two.Enabled = True
End If

I just can't seem to get this. Help!!!!!
Thanks!!!!
 
If Question1 is a YesNo only, I would make it either an
option group or a ComboBox (to eliminate having to deal
with other entries). Assume it's a ComboBox
(cboQuestion1).

cboQuestion1_LostFocus()

' check if the question was answered
If IsNull([cboQuestion1]) Or [cboQuestion1] = "" Then
MsgBox "You forgot to answer Question One. " _
& "Please try again", vbOKOnly, "Oops!"
cboQuestion1.SetFocus
Exit Sub
End If

' if answer = Yes, enable question two
If [cboQuestion1] = "Yes" Then
txtQuestionTwo.Enabled = True
txtQuestionTwo.SetFocus
Else
NextControl.SetFocus
End If

Hope this helps!

Howard Brody
 
Back
Top