Lock field based on another value

Posted on 2007-10-01
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

    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 119

    Assisted Solution

    by:Rey Obrero
    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

    Thank you both.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now