Results 1 to 3 of 3

Access 2010 using DateAdd in VBA SQL string

  1. #1
    mickelb is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    4

    Access 2010 using DateAdd in VBA SQL string

    I can't find the answer to this problem after extensive searching the web.



    I am trying to update a module to add extra functionality to cater for GDPR.

    I have added:

    strSQL = "SELECT * FROM [" & tblName2 & "] WHERE PROCESSDAY<=DateAdd("yyyy",-5,Date())"

    and get a Compile error Expected: end of statement with the yyyy highlighted. Any ideas?

    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    6,367
    you cant put quotes inside quotes.

    Either use a query, (which doesnt need quotes)
    or
    strSQL = "SELECT * FROM [" & tblName2 & "] WHERE PROCESSDAY<=#" & DateAdd("yyyy",-5,Date()) & "#"

  3. #3
    mickelb is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    4

    Thumbs up

    Many thanks, now to to sort the rest of the code!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DateAdd function in Access report
    By Niko in forum Reports
    Replies: 13
    Last Post: 10-09-2017, 11:03 PM
  2. Replies: 6
    Last Post: 07-07-2014, 08:13 AM
  3. Replies: 7
    Last Post: 08-14-2013, 02:57 PM
  4. Replies: 0
    Last Post: 07-31-2012, 11:25 AM
  5. DateAdd error in MS Office 2010
    By Noah4x4 in forum Access
    Replies: 7
    Last Post: 03-15-2011, 04:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums