prevent users changing information after entry

L

Lorna

I need to restrict users from changing a key field in a record after they
have added it but none of the form events seem to allow this without
preventing them adding further records.

This seems like a regular requirement but i can't find anything about it
anywaher.... any help would be greatly appreciated!
 
K

Keith Wilby

Lorna said:
I need to restrict users from changing a key field in a record after they
have added it but none of the form events seem to allow this without
preventing them adding further records.

This seems like a regular requirement but i can't find anything about it
anywaher.... any help would be greatly appreciated!

Test for null in this field in the form's current event and set the
properties of the text box accordingly.

If IsNull(Me.txtMyTextBox) Then
Me.txtMyTextBox.Locked = False
Else
Me.txtMyTextBox.Locked = True
End If

HTH - Keith.
www.keithwilby.com
 
A

ansentry

In the OnCurrent event of your form:


Code
-------------------
If Me.NewRecord = True Then

Me.NameOfYourControl.Locked = False

Else

Me.NameOfYourControl.Locked = True

End If

-------------------


In the After Update of the control;


Code
-------------------
Me.NameOfYourControl.Locked = Tru
-------------------



I would change the caption on the form to reflect the condition of th
control & Change the back colour of the control when it is locked.


Hope this is a help.


Regards,

John
 
L

Lorna

Keith

Thanks.... i had the code but was putting in against the field rather than
the form event.

Thanks again - very helpful and prompt!

Lorna
 
K

Keith Wilby

Lorna said:
Keith

Thanks.... i had the code but was putting in against the field rather than
the form event.

Thanks again - very helpful and prompt!

Lorna

You're welcome, glad to help.

Keith.
 
P

Peter R. Fletcher

One other thought - it is relatively unusual to need to allow users to
touch key fields. It is (IMHO) preferable to use autonumber key fields
that the users don't have access to. Other fields can be indexed with
no duplicates allowed, it that is what you want, but key fields should
be protected from interference.

I need to restrict users from changing a key field in a record after they
have added it but none of the form events seem to allow this without
preventing them adding further records.

This seems like a regular requirement but i can't find anything about it
anywaher.... any help would be greatly appreciated!

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
N

NewKidontheBlock

Lorna

This response my be way too late for your purposes but I just came across
your post while looking for something else.

I encountered a similar problem and posted a question on this form. The
answers I got may assist you. The post was headed 'Coding MsgBox Responses'

Kind regards

Tony
 
Top