date function returning null in access


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: date function returning null in access

  1. #1
    Jreg Guest

    date function returning null in access

    if anyone has any ideas as to why the date function is returning null in my
    access code i would greatly appreciate it. here is the code i have in my
    access form:

    Private Sub Form_Current()
    If Due_Date_.Value < Date Then
    Due_Date_.BackColor = vbRed
    Else
    Due_Date_.BackColor = vbGreen
    End If
    End Sub

    the date function works fine i all of my other office apps. just not here in
    access where i could really use it.

    thanks in advance
    Glenn (Jreg)




  2. #2
    Sue Harsevoort Guest

    Re: date function returning null in access

    I don't think your problem is that the Date function is returning null, at
    least it doesn't return null for me, but if I used code simillar to yours I
    did have a problem and the back color would always be Green. The problem I
    think you are having is that Due_Date_.Value is a text value and not a date.
    If you change it to If CDate(Due_Date_.Value) < Date Then, I think it should
    work for you.

    Sue

    "Jreg" <Jedireg@usa.net> wrote in message news:3b0e61f3@news.devx.com...
    > if anyone has any ideas as to why the date function is returning null in

    my
    > access code i would greatly appreciate it. here is the code i have in my
    > access form:
    >
    > Private Sub Form_Current()
    > If Due_Date_.Value < Date Then
    > Due_Date_.BackColor = vbRed
    > Else
    > Due_Date_.BackColor = vbGreen
    > End If
    > End Sub
    >
    > the date function works fine i all of my other office apps. just not here

    in
    > access where i could really use it.
    >
    > thanks in advance
    > Glenn (Jreg)
    >
    >
    >




  3. #3
    Paul Clement Guest

    Re: date function returning null in access

    On Fri, 25 May 2001 09:55:53 -0400, "Jreg" <Jedireg@usa.net> wrote:

    if anyone has any ideas as to why the date function is returning null in my
    access code i would greatly appreciate it. here is the code i have in my
    access form:

    Private Sub Form_Current()
    If Due_Date_.Value < Date Then
    Due_Date_.BackColor = vbRed
    Else
    Due_Date_.BackColor = vbGreen
    End If
    End Sub

    the date function works fine i all of my other office apps. just not here in
    access where i could really use it.

    thanks in advance
    Glenn (Jreg)



    Are you sure that it isn't the underlying value of Due_Date_ that is Null?

    You can check this using the IsNull function prior to comparing it to another value or converting it
    to another data type.


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center