Trying to get a checkbox to be true if form opens for new record entry

Posted on 2014-07-16
Last Modified: 2014-07-18
I'm trying to get a checkbox to be true if a form opens for a new record data entry.  Here's my code.  I've tried on onopen and onload and neither method checks the checkbox true.

    If Me.NewRecord = True Then
       Me.chkbxNewRecord = True
    End If
Question by:SteveL13
    LVL 33

    Accepted Solution

    You need to put the code into the on Current event.  The Open and Load are "form" level events and run once for the form.  The Current event is a "record" level event and runs once for each record when you first move to it.
    LVL 31

    Expert Comment

    It is best to use code like this, to guarantee that the checkbox will be unchecked for a record that is not a new record (also, use the bang (!) for members of collections, such as controls on a form):

    Me![chkbxNewRecord].Value = Me.NewRecord

    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!

    Join & Write a Comment

    Suggested Solutions

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    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…

    728 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

    15 Experts available now in Live!

    Get 1:1 Help Now