Results 1 to 8 of 8

Thread: Autofill Date

  1. #1
    Join Date
    May 2005
    Posts
    1,191

    Unanswered: Autofill Date

    I have a search form which has a date text box in it. Upon clicking a button, I want it to automatically fill in today's date if there isn't anything in it. So far this is the code I have
    PHP Code:
    If Me.TxtBoxDateReqTo Null Or Me.TxtBoxDateReqTo "" Then
        Me
    .TxtBoxDateReqTo Date
    End 
    If 
    This however, does not work. I know the 2nd line is correct (after testing), so I know the "if" qualifications must be wrong. Anyone know what it should be reading. Thank you in advance to anyone who can help.
    Me.Geek = True

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    He he, Null isn't equal to anything, not even Null

    Here are two other tests that might be used in stead, let your preferences guide you to which one to chose...

    if len(Me!TxtBoxDateReqTo.value & vbnullstring) > 0 then

    if trim$(Me!TxtBoxDateReqTo.value & "") <> "" then
    Roy-Vidar

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    Hey Roy,

    Thanks for the help. Unfortunately, neither option ended up solving the problem. I'd appreciate any other help anyone can offer. Thanks again Roy.
    Me.Geek = True

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    If nz(TxtBoxDateReqTo, "") = "" Then
    Me.TxtBoxDateReqTo = Date
    End If
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    May 2005
    Posts
    1,191
    Thanks Teddy. That seems to do the trick.
    Me.Geek = True

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    You did go lookup how nz() works now, right?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    May 2005
    Posts
    1,191
    Of course!
    You can use the Nz function to return zero, a zero-length string (" "), or another specified value when a Variant is Null. For example, you can use this function to convert a Null value to another value and prevent it from propagating through an expression.

    Syntax

    Nz(variant[, valueifnull])
    Me.Geek = True

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Ahhhhh, that should give me the warm fuzzies for at least another hour...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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