Lock Editing of a single field

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

Guest

I have a customer information and order database set up. The primary
information is all entered through a main form with multiple sub-forms. I am
trying to figure out how to prohibit users from editing a single field within
the main form once it has been entered. I have figured out how to lock
editing for all fields, but that prohibits updating some information that
must be updated regularly. I also know that you can lock any one particular
field, but that prohibits entering information into that field for "new
records". Does anybody have a solution to this?
 
You will want to use two different events to control this. First, in the
form's Current event, set the Locked property based on whether or not it is a
new record:

Me.txtSomeControl.Locked = Not Me.NewRecord

The second part is optional depending on your business rules. If you want
the control to be editable until the record is updated, no action is
necessary; however, if you want to lock the control as soon as the control is
updated, use the After Update event of the control to lock it:

Me.txtSomeControl.Locked = True
 
Thanks a lot. This seems to be getting me somewhere. The name of the field is
"Client Name" do I still need the "txt" infront of the name. I am getting an
error message for "invalid qualifier" when I enter this code:

Private Sub Form_AfterUpdate()
Me.Client Name.Locked = True
End Sub

Private Sub Form_Current()
Me.Client Name.Locked = Not Me.NewRecord
End Sub

Forgive me, I am pretty new to writing any code. Thanks for all the help!!
 
Klatuu,

Please disregard my previous post. I figured it out. I removed the space in
the field name and everything seems to be working now. Thanks again for all
of your help!!
 
Back
Top