+ Reply to Thread
Results 1 to 8 of 8

Access ADO - SQL query (3 cell values)

  1. #1
    Registered User
    Join Date
    03-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    17

    Access ADO - SQL query (3 cell values)

    Hi Guys,

    I am trying to run a SQL query based on 3 cell values within the workbook. The 3 variables are >= "StartDate", <="EndDate" and "Employee"

    Im able to successfully query the StartDate & EndDate but when adding Employee i'm getting a "Syntax error (missing operator) in query expression

    Below is the SQL code used

    Please Login or Register  to view this content.
    Any help would be much appreciated

    Thanks, Dan

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Access ADO - SQL query (3 cell values)

    Your missing the "="
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Access ADO - SQL query (3 cell values)

    Hi Mike

    Thanks for your reply - when I use your code i'm now given the following error

    "Run-time error'-2147217900 (80040e14)':
    Syntax error in query expression '(((Employee ='Dan' AND EntryDate)>=11/07/2012 AND (EntryDate <=28/07/2012));'.

    I have confirmed that there is data within the DB that meets this criteria

    Any ideas are much appreciated

    thanks

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Access ADO - SQL query (3 cell values)

    Sorry I just done it off the top of my head. This should work

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Access ADO - SQL query (3 cell values)

    Hi Mike

    Just tried the above and still seem to be getting the Syntax error

    Thanks

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Access ADO - SQL query (3 cell values)

    Sorry again but this should work
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Access ADO - SQL query (3 cell values)

    Hi Mike

    Excellent, worked a treat! I just took out the "CDate" function as the dates are stored as a number in the worksheet

    Thanks alot for your support

    Dan

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Access ADO - SQL query (3 cell values)

    If you are satisfied with the solution(s) provided, please remember to mark your thread as Solved.

    New quick method:
    Select Thread Tools (above first post on page) -> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word "Title" you will see a dropdown with the words "No prefix".
    Change to "Solved"
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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