using check box to control text box visibility

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In my main form I have a check box which controls whether a combo box is
active or not. Then, I have a text box in a subform which I only want
displayed when the check box has been ticked.

I’m using this script:

If Forms![frmTasksCompleted].chck_Completed.Value = True Then
Me.Text4.Visible = True

But the text box does not appear (it’s deault value for visible is false)

Can anyone help?

Thnx
 
In the AfterUpdate event of the checkbox, type this code:

Private Sub MyCheckBox_AfterUpdate()

Me.Text4.Visible = MyCheckBox

End Sub

That's all you need to do.

HTH

Anthony
 
That won't work, Anthony. The original poster stated that the text box is on
a subform, but the checkbox is on the parent form. What's required,
therefore, is:

Private Sub MyCheckBox_AfterUpdate()

Me.SubformControlName.Form!Text4.Visible = MyCheckBox

End Sub

where SubformControlName is the name of the control on the main form that
holds the form being used as the subform. Depending on how the subform was
added to the main form, the control name may not be the same as the name of
the form being used as a subform.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Anthony said:
In the AfterUpdate event of the checkbox, type this code:

Private Sub MyCheckBox_AfterUpdate()

Me.Text4.Visible = MyCheckBox

End Sub

That's all you need to do.

HTH

Anthony

alcoalex said:
In my main form I have a check box which controls whether a combo box is
active or not. Then, I have a text box in a subform which I only want
displayed when the check box has been ticked.

I'm using this script:

If Forms![frmTasksCompleted].chck_Completed.Value = True Then
Me.Text4.Visible = True

But the text box does not appear (it's deault value for visible is false)

Can anyone help?

Thnx
 
Sorry, thank you Douglas.

Yes, alcoalex, Douglas is right.

Douglas J. Steele said:
That won't work, Anthony. The original poster stated that the text box is
on a subform, but the checkbox is on the parent form. What's required,
therefore, is:

Private Sub MyCheckBox_AfterUpdate()

Me.SubformControlName.Form!Text4.Visible = MyCheckBox

End Sub

where SubformControlName is the name of the control on the main form that
holds the form being used as the subform. Depending on how the subform was
added to the main form, the control name may not be the same as the name
of the form being used as a subform.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Anthony said:
In the AfterUpdate event of the checkbox, type this code:

Private Sub MyCheckBox_AfterUpdate()

Me.Text4.Visible = MyCheckBox

End Sub

That's all you need to do.

HTH

Anthony

alcoalex said:
In my main form I have a check box which controls whether a combo box is
active or not. Then, I have a text box in a subform which I only want
displayed when the check box has been ticked.

I'm using this script:

If Forms![frmTasksCompleted].chck_Completed.Value = True Then
Me.Text4.Visible = True

But the text box does not appear (it's deault value for visible is
false)

Can anyone help?

Thnx
 
You have not indicated whether that checkbox is bound or unbound. If
it is bound then I believe you will also have to add the same code in
the oncurrent event of the main form.

Me.SubformControlName.Form!Text4.Visible = me.MyCheckBox


Ron
 
Back
Top