Access - Object Required error

Posted on 2009-02-10
Last Modified: 2013-11-28
I am trying to update a date field with the current date if a cmd button is hit and the field is empty. If the field is not empty I want to jsut close the form
This is the code I am using. When I hit the command button I get Object Required error. What would be a better way so that this works.

     If Me.date_complete Is Null Then
        Me.date_complete = Date

    End If
Question by:Pdeters
    LVL 77

    Accepted Solution


    If Isnull(Me.date_complete) Then
            Me.date_complete = Date()
            DoCmd.Close acform,
            DoCmd.Close  acform,
     End If

    I think it is a good idea to be explicit about what you are closing, just in case something else manages to get focus.
    LVL 28

    Expert Comment

    You need to use the IsNull function rather than the Is Null comparison
    Cheers, Andrew
        If IsNull(Me.date_complete) Then
            Me.date_complete = Date
        End If

    Open in new window


    Author Closing Comment

    I did not know about IsNull - thank you

    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.

    Join & Write a Comment

    Suggested Solutions

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
    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 …

    754 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

    22 Experts available now in Live!

    Get 1:1 Help Now