Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking fields after data entry

Status
Not open for further replies.

varich

Technical User
Aug 26, 2009
17
US
Okay, I’ve almost have most of the bugs worked out so I can release my project to the masses. One of the items I have left is:
I have a data entry form. How can I lock one or more fields on the form after data has been entered onto that form. For example, once someone enters a last name, first name, ssn, DOB etc. the form now allows them to go back over that data and they can over write it. How can I prevent that, on specific fields. On other fields, users need to be able to update fields as needed.
 
Yes, that would be ideal. By in my world, they (one in particular) have very hard heads. The data is too important to allow the to write over it. I appreciate your sentiment. But do you have an idea how I can make these fields write once only?
 
You could write a code to set the locked property of controls in the after update event of the controls. If you aren't worried about individual fields/controls, you could use code in the after update of the form.

Duane
Hook'D on Access
MS Access MVP
 
I have a similar situation. What I have done is use a form for input which is opened in "Add" mode meaning no existing records can be amended.

A second (identically formatted) form is opened in "Edit" mode allowing no new records. The controls I want to be protected are locked so cannot be amended.

Hope this helps.
 
How do I set a field on a form to locked after data has been entered into it and then that field is exited? I’ve tried to create a macro, but for some reason, I keep getting errors.
 
How do you open a form in Add mode and Edit mode?
 
You could also check fields in Before Update and notify user they are changing an existing record. This won't stop them but does give fair notice.

If Not IsNull(Me.txtEmpFirst.OldValue) Then
If ((Me.txtEmpFirst.OldValue) <> Me.txtEmpFirst) Then 'they are changing the first field
If MsgBox("You previously set up a First Name for this record." & vbCrLf & vbCrLf & "If you want to add a new Employee use the 'Add Rec' button." & vbCrLf & vbCrLf & "Are you sure you want to change this record?", vbYesNo, "Continue?") = vbYes Then
'If MsgBox("You previously set up a First Name for this record - are you sure you want to change it?" & vbcrlf & vbcrlf & "If you want to add a new Employee use the 'Add Rec' button.", vbYesNo) = vbYes Then
'do nothing
Else
Cancel = True
Me.txtEmpFirst.Undo
Exit Sub
End If
End If
End If
 
To open a form in "add" or "edit" mode, open them using a macro and set the properties of the "open form" action appropriately.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top