Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2005
    Posts
    18

    Unanswered: Delete Query Question

    In using the following in a delete query I am getting an error message stating "Undefined function 'Date' in expression". I want to delete all records more than a week old.

    Code:
    <=DateAdd("d",-7,Date())

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Sounds like a references problem to me.

    The code is correct.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Go into any VBA code window and select Tools - References. Check for missing ones, remove them and then re-add them if they're missing.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Hm'm. If you're doing this in Access's QBE query designer, it should work. Are you trying this in a query using VBA? VBA/SQL might not like the double-quotes (") around the "d", and it's taking it out on the poor Date() function. What's more, I don't have a clue what I would use if I were doing this in VBA. Maybe try removing it from VBA and put it in the QBE query designer and run it from VBA using the DoCmd.OpenQuery () command.

    Hope this helps,
    Sam

  5. #5
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    Have you tried just using "<=Date() - 7"?

    You can even drop the parentheses and just use "<=Date - 7".

    C

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I still put my money on a references problem.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I'm afraid I have to boycott canupus suggestion - do the right thing and stick with DateAdd().
    George
    Home | Blog

  8. #8
    Join Date
    Nov 2005
    Posts
    18
    It was the reference issue. Fixed! Thanks for the help.

  9. #9
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    George--

    I know...I know. I was just trying to see if it would still cause the error.

    C

Posting Permissions

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