MS Access 2003 and 2007 Add a checkbox then automatically update the date field with the current date

Posted on 2008-11-04
Last Modified: 2013-11-28
Need to know how to add a checkbox, and when the check box is checked, insert current date into the date
field box.  How do I do the statement in the expression builder?
Question by:friskee
    LVL 74

    Accepted Solution

    Add a checkbox to the from
    Then use code like this to insert the date:

    Sub YourCheckBox_AfterUpdate()
        If me.YourCheckBox=True then
        end if
    End sub

    You will, of course, have to modify this and add your specific data entry validation rules.


    Author Comment

    It's not working- here's the code:
    Sub ChkSold_AfterUpdate()
    If Me.ChkSold = True Then
            Me.txtSoldDate = Date
        End If
    End Sub

    txtSoldDate control source is the sale date field in my sale table
    txtSoldDate is the name
    What else could I be doing wrong?
    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    This is fairly standard code.
    I can't see a reason why it might not work.

    Please Post a sample of this database.


    Author Comment

    I tried it again.  IT WORKS-  thank you that answer was straight forward and simple.  increased points
    come back and answer me anytime-

    Author Closing Comment

    Simple fast response- Wonderful!
    LVL 74

    Expert Comment

    by:Jeffrey Coachman

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 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

    11 Experts available now in Live!

    Get 1:1 Help Now