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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking a Field After Input

Status
Not open for further replies.

mpsDA

IS-IT--Management
Jul 27, 2005
43
GB
Can a Field be locked after a user enters data into the field, to prevent anyone making amendments at a later stage.
 
mpsDA,

Yes you can all you have to do is place the code under the after update property of the field. The code should read like this me.field.locked
 
Nope this dont work. It still allows me to change it. When I make a change to existing data it goes into debugger mode.

Let explain what i have in this field...I have a filed to record date of inputting a record. The user enters the date on creating this record. I've managed to allow the field to accept only the Current Date, which work fine.

Now i would like to protect it after input, so it cannot be ammened later by anyone else.
 
Actually it should look like this:

Private Sub MyField_AfterUpdate()
Me.MyField.Locked = True
End Sub

What I do is let the user finish the form and then at the end they have to press the SAVE button or something. Behind the save button couple of things are updated:

1. Saved checkbox - hidden
2. Last Modified by with date and time - etc.

So on the current form and load event property of the form the following happens:

if me.saved.value = true then
me.field1.locked = true
else
me.field1.locked = false
end if

You don't have to have a saved checkbox. You can reference any field that can be checked against.

Hope this helps.

:)WB
 
Oops!! Forgot to set focus.

Private Sub MyField_AfterUpdate()
Me.NextField.SetFocus
Me.MyField.Locked = True
End Sub


:)WB
 
Why not simply set the DefaultValue to =Date() and the Enabled property to False ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
Your solution will not work since the user is entering DATA and not DATE.

:)WB
 
the user is entering DATA and not DATE
This isn't my understanding ...
mpsDA said:
I've managed to allow the field to accept only the Current Date

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
My Bad. Didn't read all the info on the second posting by the user. Yes your solution would work just fine except I would make the default property locked so the date is not grayed out. Just a personal preference here. Adjust according to your taste buds.

With my long winded solution you are able to lock more than one field after the record has been "saved".

:)WB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top