+ Reply to Thread
Results 1 to 4 of 4

Syntax error in date in query expression "#".

  1. #1
    Registered User
    Join Date
    10-20-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    40

    Syntax error in date in query expression "#".

    Hey guys!

    I have an issue I cant seem to resolve.

    I am running a query where an excel report will pull agent data from an access database into an excel table. I need it to filter out agents that have a term date older than 90 days. My term date column in access is [TERM_DATE] and it is set to Short Date format. So in the query, I have it check a bunch of other parameters that works fine such as MU_ID, AGENT_NAME etc.

    Here is my SQL query:
    Please Login or Register  to view this content.
    The results of this query: it only pulls agents to have a term date set in the database that is not older than 90 days and excludes all the other agents that have a null/blank [TERM_DATE]. When I add the 'OR Is Null' to the query:
    Please Login or Register  to view this content.
    It ignores ALL the other parameters and pulls all 500 agents who have a null [TERM_DATE]

    So, in summary, I cannot get the SQL query to Access to filter out agents who have a [TERM_DATE] older than 90 days while still filtering the other parameters and still pulling agents who have a null/blank [TERM_DATE]


    While trying to fix this I noticed that my [TERM_DATE] column was text. So I changed it to short date instead and now my second problem is, my update macro gives me an expression error on the date. Here is my code:

    Please Login or Register  to view this content.
    So really, 2 issues. I cant filter results and I cant update my database.
    Last edited by baijixu; 06-12-2014 at 06:29 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Syntax error in date in query expression "#".

    What do you have in fields MU1-MU5?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-20-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    40

    Re: Syntax error in date in query expression "#".

    MU_ID is the business unit ID number for our team configuration, which is different than the Access ID that is auto assigned per entry. So the MU1-5 is checking excel cells for each MU_ID to lookup. In the spreadsheet, one would choose an MU or business and MU1 - MU5 would populate with an MU_ID associated with that MU to feed the query parameters.

    A row in my database looks like this:
    Please Login or Register  to view this content.
    So essentially, I want the query to pull by MU_ID, SUPERVISOR and if TERM_DATE is null or less than 90 days old.
    Last edited by baijixu; 06-12-2014 at 07:03 PM.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Syntax error in date in query expression "#".

    If you want dates older than 90 days in the past, you will need to change the greater than sign to a less than sign in your SQL statement, as you are looking for dates that have values less than 90 days ago. Access stores dates as numerical values beginning with Jan 1, 1900. Today, June 12 would be 41802 and 90 days ago would be 41712. I hope this helps.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Syntax error (Missing operator) in query expression
    By lengwer in forum Access Tables & Databases
    Replies: 2
    Last Post: 08-22-2013, 04:00 PM
  2. Syntax Error in Query Expression
    By acmagyar in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2013, 03:11 PM
  3. [SOLVED] Find expression causing "Subscript out of range" error
    By aseret in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-08-2013, 12:05 AM
  4. Syntax Error (missing Operator) in query expression
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-25-2011, 11:59 AM
  5. [SOLVED] Syntax error (missing operator) in query expression '6 Wescott Rd#
    By shealy in forum Excel General
    Replies: 0
    Last Post: 06-09-2005, 05:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1