Lock on save

  • Thread starter Thread starter JenK
  • Start date Start date
J

JenK

I would like to have a save record button on my form, that, when pressed will
save the record and lock it from changes. I want this because I have users
constantly overwritting compnay names, adresses and so on. can anyone help me
with coding of this. I am using both macros and coding.
 
I accomplish this by adding an column in my table called lockout and make it
a yes/no datatype and set its default value to true. Then I add this code to
the form.

Private Sub Form_Load()
If Me.Lockout = True Then
Me.AllowEdits = False
End If
End Sub
 
Open the form in design view, and set its AllowEdits property to No, leaving
AllowAdditions as Yes. You can now enter new records, and view (but not
edit) existing ones. You probably want to set AllowAdditions to No as well.

If you do want the user to be able to unlock the form for editing (i.e. you
just want to reduce accidental changes), see:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html

Download the example, and paste into your database. (This is copy'n'paste
stuff.)
 
Back
Top