[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

Access - Object Required error

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
        DoCmd.Close

    Else
        DoCmd.Close
    End If
0
Pdeters
Asked:
Pdeters
1 Solution
 
peter57rCommented:
Use

If Isnull(Me.date_complete) Then
        Me.date_complete = Date()
        DoCmd.Close acform, me.name
 Else
        DoCmd.Close  acform, me.name
 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.
0
 
TextReportCommented:
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
    DoCmd.Close

Open in new window

0
 
PdetersAuthor Commented:
I did not know about IsNull - thank you
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now