enable/disable textbox based on a check box

R

Ricoy-Chicago

I cehcekd the treads already but I could not find an answer to my problem...

I am using Access XP.

I have a form with several textboxes and check boxes, a check box is named
HS_Diploma, if HS_Diploma is checked then the textbox HS_Graduation_Year
should be enabled (so the year can be typed), then the user continues filling
the rest of the form. The form disables the HS_Graduation_Year in the Open
Event.

This is the coding I am using in the Click event of the HS_Diploma check box:

If [HS_Diploma].Value = Checked Then
[HS_Graduation_Year].Enabled = True
Else
[HS_Graduation_Year].Enabled = False
End If

The HS_Graduation_Year remains disabled, I pasted the coding to the Before
Update and After update events for the check box to no avail, please help.

Thanx.
 
J

Jay

Someone smarter than me is bound to post a better response, but speaking from
personal experience, I always have issues using Checked for checkboxes.

Have you tried using 1 for checked? And I think 0 is unchecked. I find I
have fewer issues with that.

I used MsgBox [HS_Diploma].Value to find out the value if it's checked and
went from there.

Hope that helps.
Jay
 
D

Dirk Goldgar

Ricoy-Chicago said:
I cehcekd the treads already but I could not find an answer to my
problem...

I am using Access XP.

I have a form with several textboxes and check boxes, a check box is
named HS_Diploma, if HS_Diploma is checked then the textbox
HS_Graduation_Year should be enabled (so the year can be typed), then
the user continues filling the rest of the form. The form disables
the HS_Graduation_Year in the Open Event.

This is the coding I am using in the Click event of the HS_Diploma
check box:

If [HS_Diploma].Value = Checked Then
[HS_Graduation_Year].Enabled = True
Else
[HS_Graduation_Year].Enabled = False
End If

The HS_Graduation_Year remains disabled, I pasted the coding to the
Before Update and After update events for the check box to no avail,
please help.

This line:
If [HS_Diploma].Value = Checked Then

should be

If [HS_Diploma].Value = True Then

You'll need this logic in either the AfterUpdate or Click event of
[HS_Diploma] -- but not both of those events -- and also in the form's
Current event, to deal with records that have already been entered.
 
R

Ricoy-Chicago

Thank you, Dirk. That did it!

Dirk Goldgar said:
Ricoy-Chicago said:
I cehcekd the treads already but I could not find an answer to my
problem...

I am using Access XP.

I have a form with several textboxes and check boxes, a check box is
named HS_Diploma, if HS_Diploma is checked then the textbox
HS_Graduation_Year should be enabled (so the year can be typed), then
the user continues filling the rest of the form. The form disables
the HS_Graduation_Year in the Open Event.

This is the coding I am using in the Click event of the HS_Diploma
check box:

If [HS_Diploma].Value = Checked Then
[HS_Graduation_Year].Enabled = True
Else
[HS_Graduation_Year].Enabled = False
End If

The HS_Graduation_Year remains disabled, I pasted the coding to the
Before Update and After update events for the check box to no avail,
please help.

This line:
If [HS_Diploma].Value = Checked Then

should be

If [HS_Diploma].Value = True Then

You'll need this logic in either the AfterUpdate or Click event of
[HS_Diploma] -- but not both of those events -- and also in the form's
Current event, to deal with records that have already been entered.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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