How can I protect an entry in a text box on a form in Access?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am working in a form and I made an error and accidentally changed the
entry in a text box in a form. I was able to fix the problem but it got me to
thinking. Is there a way to lock or freeze an entry once it is made? I have a
form with a sub from and the main form information really is not going to be
changed much. They are part numbers and I would like to have them locked but
changeable when needed, any suggestions?

Thank you,
James
 
You could disallow edits in the form's Current event except for new records:

If Me.NewRecord Then
Me.AllowEdits = True
Else
Me.AllowEdits = False
End If

Then you could have a command button (or a label's Double Click event or
something like that if you want to be subtle about it) with code to allow
edits:

Me.AllowEdits = True

Have you thought about using a PartNumber list, or better yet a related
PartNumber table, especially if there is a PartName field or other fields in
addition to PartNumber? If you are entering the PartNumber data manually in
each record you run some risk of data entry errors; if you are storing two
fields there is data redundancy.
 
James,

Depending on the desired behavior, you can either set the form's AllowEdits
property or the Locked property of the controls you wish to protect. You
could then provide an Edit command button to unprotect the form or controls,
and use the OnCurrent event to reprotect them.

Hope that helps.
Sprinks
 
Back
Top