Hide a data input line in a form until check box selected

  • Thread starter Thread starter John Memorex
  • Start date Start date
J

John Memorex

I am new to MS Access and databases in general, so please forgive my
ignorance on what is probably a very simple question. I would like to create
a yes/no checkbox on a form that will once validated, show a field to allow
data to be input. If the field is unchecked, the user will not see the field
to enter data, Please advice.

John
 
Use the AfterUpdate event of the checkbox to run simple code to set the
visibility of the textbox control. Here is generic procedure:

Private Sub TheCheckBoxName_AfterUpdate()
Me.NameOfTextBox.Visibility = Me.TheCheckBoxName.Value
End Sub
 
It's easy to do, but how you do it depends on whether the user is
checking the box or not.

If the user is checking the box, then you can make the text box visible
or not in the After Update event of the checkbox.

If the user is updating existing data, but where the checkbox is already
filled in or not, use the On Current event of the form to make the text
box visible/invisible.

John
 
Ken said:
Use the AfterUpdate event of the checkbox to run simple code to set the
visibility of the textbox control. Here is generic procedure:

Private Sub TheCheckBoxName_AfterUpdate()
Me.NameOfTextBox.Visibility = Me.TheCheckBoxName.Value
End Sub
I am new to MS Access and databases in general, so please forgive my
ignorance on what is probably a very simple question. I would like to
[quoted text clipped - 6 lines]


Ken:

Thank you for the example procedure. As I mentioned, I am a true novice at
this. If it is not too much trouble, can you explain what is happening in
this routine? Specifically the (Me.Nameof TextBox.Visibility = Me.
TheCheckBoxName.Value). Thanks.
 
J. Goddard said:
It's easy to do, but how you do it depends on whether the user is
checking the box or not.

If the user is checking the box, then you can make the text box visible
or not in the After Update event of the checkbox.

If the user is updating existing data, but where the checkbox is already
filled in or not, use the On Current event of the form to make the text
box visible/invisible.

John
I am new to MS Access and databases in general, so please forgive my
ignorance on what is probably a very simple question. I would like to create
[quoted text clipped - 3 lines]


J. Goddard:

Thank you for the help, but as a newbie, I am having a difficult time
deciphering the different functions. Can you expand on your answer or point
me to a resource for additional information? Thanks
 
John Memorex said:
Ken said:
Use the AfterUpdate event of the checkbox to run simple code to set the
visibility of the textbox control. Here is generic procedure:

Private Sub TheCheckBoxName_AfterUpdate()
Me.NameOfTextBox.Visibility = Me.TheCheckBoxName.Value
End Sub
I am new to MS Access and databases in general, so please forgive my
ignorance on what is probably a very simple question. I would like to
[quoted text clipped - 6 lines]


Ken:

Thank you for the example procedure. As I mentioned, I am a true novice
at
this. If it is not too much trouble, can you explain what is happening in
this routine? Specifically the (Me.Nameof TextBox.Visibility = Me.
TheCheckBoxName.Value). Thanks.

Actually, Ken made a slight mistake in his reply. It should be

Me.NameOfTextBox.Visible = Me.TheCheckBoxName.Value

All controls have a property named Visible which, as the name implies,
controls whether or not the control is visible. That property accepts values
of True or False, which happens to be what the values of a Check Box are.
What the code is doing is setting the Visible property of the Text Box to
the same value as the Check Box. In other words, if the Check Box is checked
(i.e.: its value is True), the Text Box will be visible, otherwise it won't
be.
 
Douglas J. Steele said:
Actually, Ken made a slight mistake in his reply. It should be

Me.NameOfTextBox.Visible = Me.TheCheckBoxName.Value

Yep, shows what happens to us old geezers when the brain is thinking while
the fingers are typing. Thanks < s >.
 
Thank you for the clarification. It worked perfectly.

John
[quoted text clipped - 16 lines]
this routine? Specifically the (Me.Nameof TextBox.Visibility = Me.
TheCheckBoxName.Value). Thanks.

Actually, Ken made a slight mistake in his reply. It should be

Me.NameOfTextBox.Visible = Me.TheCheckBoxName.Value

All controls have a property named Visible which, as the name implies,
controls whether or not the control is visible. That property accepts values
of True or False, which happens to be what the values of a Check Box are.
What the code is doing is setting the Visible property of the Text Box to
the same value as the Check Box. In other words, if the Check Box is checked
(i.e.: its value is True), the Text Box will be visible, otherwise it won't
be.
 
Ken,

Thanks for your help. Despite the typo the information was great. You and J.
Goddard are terrific.

John
 
Back
Top