Enable textbox after check

G

Guest

I currently have a form that has text boxes and one checkbox. Two of the
text boxes in the form are visible but are set to disabled. I need for these
two text boxes to enable once the checkbox has been checked. How can I do
this?

The checkbox label is called [Study Related]
First texbox I need enabled after check is called [Study #]
Second one is called [Hours]

Thanks.
 
D

Darhl Thomason

It's not about the check box label, it's the check box itself. So in the
check box's after update event, add this code

If Me.{CheckBox name here} = True Then
Me.Study #.Enabled = True
Me.Hours.Enabled = True
Else
Me.Study #.Enabled = False
Me.Hours.Enabled = False
End If

You should also consider a standard naming convention in your database.
i.e. text box names should start with txt (txtHours), labels start with lbl
(lblStudyRelated), check boxes start with chk (chkStudyRelated), etc. It
will make your code tons easier to write and troubleshoot.

I would also recommend against having spaces in your object names, it tends
to complicate things. Separate words with capital letters
(lblStudyRelated).

More detail can be found at http://support.microsoft.com/kb/q110264/. There
are plenty of other places on the web that talk about this, here's a google
search on it
http://www.google.com/search?hl=en&q=database+naming+conventions&btnG=Google+Search

Good luck,

Darhl
 
G

Guest

Thank you so much Darhl. It worked perfectly but I do have one more
question. When I check the check box everything works fine because I am able
to enter text in the two textboxes but when I uncheck it, it doesn't work the
same. Meaning that it doesn't clear what I entered in the boxes. Any
suggestions?


Darhl Thomason said:
It's not about the check box label, it's the check box itself. So in the
check box's after update event, add this code

If Me.{CheckBox name here} = True Then
Me.Study #.Enabled = True
Me.Hours.Enabled = True
Else
Me.Study #.Enabled = False
Me.Hours.Enabled = False
End If

You should also consider a standard naming convention in your database.
i.e. text box names should start with txt (txtHours), labels start with lbl
(lblStudyRelated), check boxes start with chk (chkStudyRelated), etc. It
will make your code tons easier to write and troubleshoot.

I would also recommend against having spaces in your object names, it tends
to complicate things. Separate words with capital letters
(lblStudyRelated).

More detail can be found at http://support.microsoft.com/kb/q110264/. There
are plenty of other places on the web that talk about this, here's a google
search on it
http://www.google.com/search?hl=en&q=database+naming+conventions&btnG=Google+Search

Good luck,

Darhl



Mya48 said:
I currently have a form that has text boxes and one checkbox. Two of the
text boxes in the form are visible but are set to disabled. I need for
these
two text boxes to enable once the checkbox has been checked. How can I do
this?

The checkbox label is called [Study Related]
First texbox I need enabled after check is called [Study #]
Second one is called [Hours]

Thanks.
 
B

Brian Bastl

If Me.{CheckBox name here} = True Then

Me.Study #.Enabled = True
Me.Hours.Enabled = True

Else

Me.Study # = ""
Me.Study #.Enabled = False
Me.Hours = ""
Me.Hours.Enabled = False

End If

Brian

Mya48 said:
Thank you so much Darhl. It worked perfectly but I do have one more
question. When I check the check box everything works fine because I am able
to enter text in the two textboxes but when I uncheck it, it doesn't work the
same. Meaning that it doesn't clear what I entered in the boxes. Any
suggestions?


Darhl Thomason said:
It's not about the check box label, it's the check box itself. So in the
check box's after update event, add this code

If Me.{CheckBox name here} = True Then
Me.Study #.Enabled = True
Me.Hours.Enabled = True
Else
Me.Study #.Enabled = False
Me.Hours.Enabled = False
End If

You should also consider a standard naming convention in your database.
i.e. text box names should start with txt (txtHours), labels start with lbl
(lblStudyRelated), check boxes start with chk (chkStudyRelated), etc. It
will make your code tons easier to write and troubleshoot.

I would also recommend against having spaces in your object names, it tends
to complicate things. Separate words with capital letters
(lblStudyRelated).

More detail can be found at http://support.microsoft.com/kb/q110264/. There
are plenty of other places on the web that talk about this, here's a google
search on it
http://www.google.com/search?hl=en&q=database+naming+conventions&btnG=Google+Search

Good luck,

Darhl



Mya48 said:
I currently have a form that has text boxes and one checkbox. Two of the
text boxes in the form are visible but are set to disabled. I need for
these
two text boxes to enable once the checkbox has been checked. How can I do
this?

The checkbox label is called [Study Related]
First texbox I need enabled after check is called [Study #]
Second one is called [Hours]

Thanks.
 

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