Lock Editing of a single field

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?
 
G

Guest

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
 
G

Guest

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!!
 
G

Guest

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!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top