Lock text field once data has been entered into it.

J

jfaz

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.
 
S

Stefan Hoffmann

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 <--
 
J

jfaz

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 <--
 
S

Stefan Hoffmann

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 <--
 
J

jfaz

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 <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top