restrict edits in textbox

  • Thread starter Thread starter martin
  • Start date Start date
M

martin

Hello, My question is; how do I restrict a user from
editing a specific textbox? I have gone into the
properties of my form and changed the AllowEdit property
to No, but it restricts edits to my entire form. I only
want to restrict an edit to a specific textbox, is this
possible? I also would like to have a command button that
re-allows the edit.
 
You need to go to the Properties of the "TextBox", Click
on the Textbox in Design Mode then Right click & Select
Properties.

Then change the Property "LOCKED" from No to "Yes".

This will allow the user to go to that field but won't
allow to change anything.

Another way is to change the "ENABLED" property of the
TextBox to "NO" This will now not even let the user go to
the TextBox. However, it will show, but the background
color changes to Grey.

A third way is through code..
On the ENTER Event of the TextBox just set the Focus to a
different control on the Form & if you like you can do
other things...
Example:

Private Sub TextBoxName_Enter()
SecondControl.SetFocus
End Sub


As far as a button to then allow back a user to edit..

Through code...

On the OnClick Event of the Button just change the
property of the TextBox (The one you chose to use)

Note: when using Code, to set something to Yes, use True
to set something to No, use False

Example:

Private Sub EnableButtonName_Click()
TextBoxName.Enabled = True 'TextBox will now be enabled

OR

TextBoxName.Locked = False 'TextBox will now be enabled

End Sub


Private Sub DisableButtonName_Click()
TextBoxName.Enabled = False 'TextBox will now be enabled

OR

TextBoxName.Locked = True 'TextBox will now be enabled

End Sub


Jeff
 
Back
Top