Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Apr 2003
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Blank Date Field (2000)

    Hi all --

    I'm trying to create a date stamp. If a user selects an order as "Ordered" on a form (by clicking on a check box), today's date will automatically populate into the "ORDER_DATE" field in my table.

    My VBA is:

    Private Sub ckOrdered_Click()
    Dim OrderedDate As Date

    If ckOrdered = -1 Then
    OrderedDate = Date
    End If

    End Sub

    This all works great until the user decides "Whoops, I didn't mean to click that" and unselects the check box. In my table I can see that the ORDER_DATE field changes to 12:00:00 AM. How do I fix this so that it returns a blank date rather than 12:00:00 AM?

    Thanks,
    Kindra

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Blank Date Field (2000)

    Try

    If ckOrdered = -1 Then
    OrderedDate = Date
    Else
    OrderedDate = Null
    End If

  3. #3
    2 Star Lounger
    Join Date
    Apr 2003
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Blank Date Field (2000)

    I then get "Run Time Error 94" Invalid Use of Null

    ????

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Blank Date Field (2000)

    I assume that OrderedDate is a field in the record source of the form. What is the field type?

  5. #5
    2 Star Lounger
    Join Date
    Apr 2003
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Blank Date Field (2000)

    It's a Date field type.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Blank Date Field (2000)

    Hmmm, it should be possible to set a date field to Null.

    Do you have expressions or other code that relies on OrderedDate not being blank?

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Blank Date Field (2000)

    Is OrderedDate both the name of the field and the name of the control? Is there a constraint on the field or on the control that would keep it from allowing a Null value? Do you have an AfterUpdate event of the checkbox or a form event that tries to use the date value in the field and hasn't allowed for a possible Null value?

    Wait a minute! I just looked back at your initial post and you're dimming OrderedDate as a variable. If that is also the name of a field or control, it's likely that Access is getting confused.
    Charlotte

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Blank Date Field (2000)

    Good catch!

  9. #9
    2 Star Lounger
    Join Date
    Apr 2003
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Blank Date Field (2000)

    Ahhhh.... I see. I was making things more complicated than they needed to be. I used the actual field in my table, ORDER_DATE in my If... Then statement. Thanks much!

    [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •