enabling controls based on previous control

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!!!!
 
H

Howard Brody

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top