Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If statement with Date (A2K SR1)

    I am trying to test whether or not a date has been entered into a field. I created an after update event. If there is no date in the field, I want CustomerStatusID to = 1 and if there is a date in the field, I want CustomerStatusID to = 2.


    Private Sub CheckOutDate_AfterUpdate()
    If [CheckOutDate] = Null Then
    [CustomerStatusID] = 1
    Else
    [CustomerStatusID] = 2
    End If
    End Sub

    What appears to be happening is that CustomerStatusID is set to 2 if there is no date in field, if there is a date in the field or if a date is deleted from the field.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If statement with Date (A2K SR1)

    Try changing your If statement to:

    <pre> If ISNULL([CheckOutDate]) Then
    </pre>

    Legare Coleman

  3. #3
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If statement with Date (A2K SR1)

    Many thanks. Works fine.

    Tom

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

    Re: If statement with Date (A2K SR1)

    To expand on Legare's solution a bit, you can't eve compare null values using the "=" operator. Even Null = Null will returns a false. You have to either use the IsNull function or concatenate a string to the value and test for Len([MyControl] & "") = 0.
    Charlotte

  5. #5
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If statement with Date (A2K SR1)

    Thanks for the reason why.

    Tom

Posting Permissions

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