Enable/diable control in form view

razorking

Registered User.
Local time
Today, 14:11
Joined
Aug 27, 2004
Messages
332
I have a text box control on a form - I have the text box disabled in the properties. I want the text box to be visible on the form but I do not want it accessible at all times. I would like to be able to enable the control by use of a command button or a check box or something.

The reason I want to do this in this manner is due to the fact that the data is being input on the form via a scanner. The aforementioned text box is field that will typically auto-populate. But there are times it will need to be edited. Now...there may be other ways to approach this. But for now I am hoping that there is a way to enable/disable this text box on demand (command button or checkbox).

Anyone know how I might do this??

Thanks!
 
for the command button, put:

Me.YourTextboxNameHere.Enabled = True

and to disable:

Me.YourTextBoxNameHere.Enabled = False
 
Absolutely awesome!

Exactly what I was looking for...thanks!
 
This is the perfect situation for using a toggle button!

You said you have the textbox disabled in the Property Box; leave it like that.

Place a Toggle Button on the form. In the Toggle Button's Property Box, under the Caption Property type in Enable. Behind the Toggle Button's OnClick event, using the code Bob provided, place this:
Code:
Private Sub YourToggleName_Click()
  If YourToggleName Then
    YourToggleName.Caption = "Disable"
    Me.YourTextboxNameHere.Enabled = True
  Else
    YourToggleName.Caption = "Enable"
    Me.YourTextboxNameHere.Enabled = False
  End If
End Sub
When the form opens, the text box will be Disabled and the Toggle Button will say "Enable." Clicking the toggle will Enable the text box, and the button will now say "Disable." Clicking it again will Disable the text box once more.
 

Users who are viewing this thread

Back
Top Bottom