Yes/No options linking to other Fields

A

adrian007uk

Hi i was wondering if anybody can point me in the right direction.

I would like to know if there is anyway of using a yes/no box that when a
user changes its state to 'Yes' (in a form) a text box will appear (in the
same form) allowing ther user to enter the appropriate text. The text box
does not have to be hidden (but it would be great if it could be grayed out),
it just cannot allow text to be entered into it when the box is marked as
'No'.

Adrian
 
F

fredg

Hi i was wondering if anybody can point me in the right direction.

I would like to know if there is anyway of using a yes/no box that when a
user changes its state to 'Yes' (in a form) a text box will appear (in the
same form) allowing ther user to enter the appropriate text. The text box
does not have to be hidden (but it would be great if it could be grayed out),
it just cannot allow text to be entered into it when the box is marked as
'No'.

Adrian

Code the Check Box AfterUpdate event:
Me.[OtherControl].Enabled = Me.[CheckBoxName]

Place the same code in the Form's Current event.
 
A

Arvin Meyer [MVP]

Private Sub chkWhatever_AfterUpdate()
If Me.chkWhatever = True Then

' Uncomment the 1 you want to happen
' Me.txtOther.Enabled = True
' MetxtOther.Visible = True
Else
' Me.txtOther.Enabled = False
' MetxtOther.Visible = False
End If
End Sub

If you want this to persist after you change records and/or re-open records
you'll also need to call it in the form's Current event:

Private Sub Form_Current()
chkWhatever_AfterUpdate
End Sub
 
A

adrian007uk

Hi fredg

Thanks, that worked great.

fredg said:
Hi i was wondering if anybody can point me in the right direction.

I would like to know if there is anyway of using a yes/no box that when a
user changes its state to 'Yes' (in a form) a text box will appear (in the
same form) allowing ther user to enter the appropriate text. The text box
does not have to be hidden (but it would be great if it could be grayed out),
it just cannot allow text to be entered into it when the box is marked as
'No'.

Adrian

Code the Check Box AfterUpdate event:
Me.[OtherControl].Enabled = Me.[CheckBoxName]

Place the same code in the Form's Current event.
 
A

adrian007uk

Thanks Arvin

I thought your code was complicated but i managed to get it to work. I can
now use yours or fredg's answers as both work.

Many thanks.

Adrian
 

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