Lock text field once data has been entered into it.

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

Guest

I wish to stop users from changing text in a field once a record has been
created. I have tried a couple of methods:
On form current event:
If NotIsNull(me.area) Then
Me.area.enabled = False
Me.area.locked = True
End If

Also tried.
Again on form current event
me.allowedits = NotIsNull(me!area).

Neither one of these appears to work. Can anyone point out to me what I am
doing wrong.
Thanks in anticipation.
 
hi,
I wish to stop users from changing text in a field once a record has been
created. I have tried a couple of methods:
On form current event:
If NotIsNull(me.area) Then
Me.area.enabled = False
Me.area.locked = True
End If
You are mixing fields with controls.
Neither one of these appears to work. Can anyone point out to me what I am
doing wrong.
First rename your control area to txtArea. After that

txtArea.Locked = Not IsNull(Me![Area])

should work fine in the form current event.


mfG
--> stefan <--
 
Tried this and it will still allow me to change to text. The form is set to
datasheet - will this have any impact?

Stefan Hoffmann said:
hi,
I wish to stop users from changing text in a field once a record has been
created. I have tried a couple of methods:
On form current event:
If NotIsNull(me.area) Then
Me.area.enabled = False
Me.area.locked = True
End If
You are mixing fields with controls.
Neither one of these appears to work. Can anyone point out to me what I am
doing wrong.
First rename your control area to txtArea. After that

txtArea.Locked = Not IsNull(Me![Area])

should work fine in the form current event.


mfG
--> stefan <--
 
hi,
Tried this and it will still allow me to change to text. The form is set to
datasheet - will this have any impact?
Nope. Is your form bound to a data source?

Use the form wizard to create a new form in datasheet view. Add a form
current event:

Private Sub Form_Current()

txtArea.Locked = Not IsNull(Me![Area])

End Sub

Don't forget to rename the control to txtArea before.

This works fine for me.

btw, what Access version do you have?


mfG
--> stefan <--
 
how would Irename the control?
Stefan Hoffmann said:
hi,
Tried this and it will still allow me to change to text. The form is set to
datasheet - will this have any impact?
Nope. Is your form bound to a data source?

Use the form wizard to create a new form in datasheet view. Add a form
current event:

Private Sub Form_Current()

txtArea.Locked = Not IsNull(Me![Area])

End Sub

Don't forget to rename the control to txtArea before.

This works fine for me.

btw, what Access version do you have?


mfG
--> stefan <--
 
Back
Top