How lock field on a form if there is any value in it

I have a field on a form that I want to lock if there is any value in the field when the form opens.  How can I do this?
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
in the form CURRENT event:

with me.controlname
    .locked = not isnull(.value)
end with

Open in new window

WHERE
controlname is the NAME property of the control
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
to create a form CURRENT event:

go to the design view of the form

turn on the Property Sheet if it is not showing by pressing ALT-ENTER

click in the upper left in the square where the rulers intersect (to select the form so its details show on the Property Sheet)

on the Property Sheet, click on the Event tab

click in the Current event

choose [Event Procedure] from the list

click the Builder Button ... to the right or press Ctrl-F2

paste the code into that event between the procedure delaration and End Sub statements

change controlname to the Name property of your control

from the menu in VBE (Visual Basic Editor), choose Debug, Compile

then Save and test!

~~~~~~~~~~~~~~~~

the Current event runs each time a record is Loaded on a bound form
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.