New rule of controlling form entry

smyeong

Registered User.
Local time
Today, 22:23
Joined
Mar 17, 2003
Messages
27
Hi, Does anybody know how to set a control whereby it can restrict users from editing the previous record line once entered, the particular column will be locked; no editing is allowed. But the next new record will be unlocked again for entry.

I tried to do myself but i have found an error when i edit previous row which is not ZERO . It stated runtime error 2166 "You can't lock a control while it has unsaved changes" Then, the following new entry which is auto-given ZERO can be unlock and work accordingly.

My code as like this :
Private Sub QTY_Change()
If "" & QTY <> 0 Then
QTY.Locked = True
If "" & QTY = 0 Then
QTY.Locked = False
End If
End If
End Sub


i did use event like BeforeUpdate or AfterUpdate or On_change instead ,but it failed somehow.

What could be that problem?

Thanks
 
If this applies to all fields, you could set the form's allow additions to yes and the allow edits to no. Or is that not what you're after?
 
New Control - Locking record after entered

pbaldy said:
If this applies to all fields, you could set the form's allow additions to yes and the allow edits to no. Or is that not what you're after?
Thanks anyway. My code has finally worked out.

Private Sub Form_Current()
DoCmd.RunCommand acCmdSaveRecord

If QTY <> 0# Then
QTY.Locked = True

Else
QTY.Locked = False
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom