Which event to use?

Posted on 2012-09-11
Last Modified: 2012-09-12
I have a button on a form that is disabled by default.  I want to enable the button based on a Yes/No field in the DB record.  I use the standard navigation arrows at the bottom of the form to move forward and back in the table.

Which event do I use to put code to test the field and enable the button?.  Could I put something in the button Enabled property instead?
Question by:IBMJunkman
    LVL 75

    Accepted Solution

    Two places.

    Form Current event and the Yes/No field AfterUpdate event

    LVL 61

    Assisted Solution

    Use the form's Current Event, which runs when the form opens and as the user navigates through records..

    You should also use the After Update event of the field that is being tested.
    LVL 75

    Assisted Solution

    by:DatabaseMX (Joe Anderson - Access MVP)
    " I want to enable the button based on a Yes/No field in the DB record. "
    Well, IF ... that field in not a check box on the Form (?), then you only need the current event.

    Private Sub Form_Current()

    Me.YourCommandButtonName.Enabled = (Me![YourYesNoFieldName] = True)  ' or False

    LVL 30

    Expert Comment

    Form_Current event for a filled field.

    If you need to modify the field then, as mbizup commented, you need to use the same code in the Yes/No field after update event.
    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    "as mbizup commented, "


    Author Closing Comment

    Both options were used.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    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…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    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…

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now