Combo Bexes To Unlock Text Boxes

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

Guest

Hi,

I would like to know, if at all possible, whether or not I can programme a
check box to unlock a text box.

For example, if it is unchecked then the textbox is locked. If it is
checked, then the text box is unlocked and can be used.

I would be greatful of any ideas to this one.

Thanks,

Kieron
 
Hi Kieron,

Should be pretty straightforward. In the After Update event of the checkbox,
you just need to set the Locked property of the textbox to the value of the
checkbox. Something along the lines of...

Me.TextBox.Locked = Me.CheckBox

If you want to make the control look disabled, then try the Enabled property
instead (again using the After Update event of the check box...

Me.TextBox.Enabled = Not (Me.CheckBox)

If the value of the checkbox is stored within a/the record, then you'll also
need to add some code to handle the locked property of the textbox when the
form opens and the record is displayed.

Hope this helps,

Stuart
 
Kieron White said:
Hi,

I would like to know, if at all possible, whether or not I can programme a
check box to unlock a text box.

For example, if it is unchecked then the textbox is locked. If it is
checked, then the text box is unlocked and can be used.

I would be greatful of any ideas to this one.

Yes you can but I'm not sure of the value of such functionality - what is it
you're trying to achieve?

This code in a check box after update event should do it (untested):

If Me.chkMyCheckBox Then
Me.txtMyTextBox.Locked = True
Else
Me.txtMyTextBox.Locked = False
End If

You'd also need to do this in the form's current event, so it might be worth
trying putting it there and calling it from the check box update event.

HTH - Keith.
www.keithwilby.com
 
Back
Top