Results 1 to 6 of 6

Thread: [RESOLVED] MS Access SQL Question ...

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Resolved [RESOLVED] MS Access SQL Question ...

    I am using MS Access 2000.

    Why does this query give me a syntax error ?
    All field names are correct, and both joins should be "inner".



    VB Code:
    1. select a.QUESTION_GROUP,a.QUESTION_ID,a.WEIGHTING,a.CONTROL_MEASURE_OWNER,a.CONTROL_MEASURE_APPROVED,a.COMPLETION_TIMESCALE,b.CONTROL_MEASURE,c.QUESTION
    2. from AUDIT_LOCATION_QUESTION_RESULTS a
    3. inner join AUDIT_CONTROL_MEASURES b on (a.CHAIN=b.CHAIN and a.QUESTION_GROUP=b.QUESTION_GROUP and a.QUESTION_ID=b.QUESTION_ID)
    4. inner join AUDIT_GROUP_QUESTIONS c on (a.CHAIN=c.CHAIN and a.QUESTION_GROUP=c.QUESTION_GROUP and a.QUESTION_ID=c.QUESTION_ID)
    5. where a.CHAIN = '01'
    6. and a.BRANCH_NUMBER = '0001'
    7. and a.AUDIT_DATE = '20060502'
    8. order by a.QUESTION_GROUP,a.QUESTION_ID
    Last edited by Hack; May 4th, 2006 at 06:26 AM. Reason: Added [RESOLVED] to thread title

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: MS Access SQL Question ...

    If AUDIT_DATE is a Date type Field, you should change its WHERE condition to
    VB Code:
    1. a.AUDIT_DATE = #02/05/2006#

    i.e. replace the single quotes with hash marks and add /'s.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: MS Access SQL Question ...

    It isn't. Sorry should have stated that. They are strings, so I store them as YYYYMMDD.

    The error I get is :
    Attached Images Attached Images  

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: MS Access SQL Question ...

    I think it's the brackets, Access has an unusual way of using them. It may need to be like this:
    Code:
    from (AUDIT_LOCATION_QUESTION_RESULTS a 
    inner join AUDIT_CONTROL_MEASURES b on a.CHAIN=b.CHAIN ... and a.QUESTION_ID=b.QUESTION_ID) 
    inner join AUDIT_GROUP_QUESTIONS c on a.CHAIN=c.CHAIN ... and a.QUESTION_ID=c.QUESTION_ID

  5. #5

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: MS Access SQL Question ...

    Si you genius .. thats EXACTLY what it was. Works a treat now.
    I'm so used to SQL Server I couldn't get my head round what to me looks like a weird weird syntax that MS Access uses sometimes .... this being a case in point.

    I was looking at that for over an hour yesterday ... and would never have thought to do it THAT way !

    Your a life-saver ... thanks a lot

  6. #6

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: MS Access SQL Question ...

    By the way ... I tried rating your post but was told :
    "You must spread some Reputation around before giving it to si_the_geek again."

    Ironic really .. I seem to HAVE quite a reputation where I work already

Posting Permissions

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



Click Here to Expand Forum to Full Width