Lock field based on another value

Posted on 2007-10-01
Medium Priority
Last Modified: 2013-11-27
MS Access 2000. In my Data Entry form, I would like to lock a field if the user keys in "Pass" in another field.
How can I do that?
Question by:doe5
LVL 77

Accepted Solution

peter57r earned 1000 total points
ID: 19990322
You have to add code to 2 places.
In the afterupdate event procedure of the 'pass' field you put:

If me.thiscontrolname = 'pass' then
me.othercontrolname.locked = true
me.othercontrolname.locked = false
end if

The same code need to go into the Form_current event procedure so that exiating records have the same rule.
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 19990324
in the exit event or afterupdate event or lostfocus event of the control

private sub controlname_afterupdate()

if me.controlname="Pass" then
end if

end sub

Author Comment

ID: 19990454
Thank you both.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question