Results 1 to 2 of 2
  1. #1
    R_Sam is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2016
    Location
    United Kingdom
    Posts
    2

    Syntax Error in Join Operation

    Hi all,

    I've created a works tracking DBMS which also incorporates inventory management and billing/invoicing. Where a client has multiple items in for repair, the idea is to batch invoice rather than a single invoice for each item. The SQL that I've written to facilitate this keeps giving me the following error message "Syntax error in JOIN Operation". The SQL is as follows:



    JobnumPreFix = Left(JobnumPreFix, 3)
    stJobnumPreFix = JobnumPreFix & "*"


    'Query definition that identifies all the jobnumbers that are to be batch invoiced
    stSQL4 = "SELECT Lkup_tblSalutation.Salutation, tblClientName.FirstName, tblClientName.Surname, tblClientName.BusinessName, " & _
    "tblClientBusinessAddress.StreetAddress, tblClientBusinessAddress.DistrictAddress, tblClientBusinessAddress.TownAddress, " & _
    "tblClientBusinessAddress.CountyAddress, tblClientBusinessAddress.PostCode " & _
    "FROM ((Lkup_tblSalutation INNER JOIN tblClientName ON Lkup_tblSalutation.SalutationID = tblClientName.SalutationID) " & _
    "INNER JOIN tblClientName ON tblClientBusinessAddress.ClientID = tblClientName.ClientID) " & _
    "WHERE ClientID IN (SELECT tblHardwareSpecs.JobNumber, tblSummarySheet.PartName, tblSummarySheet.PartNumber, tblSummarySheet.SerNumber, " & _
    "tblSummarySheet.Description, tblSummarySheet.Cost, tblHardwareSpecs.ClientID " & _
    "FROM (tblHardwareSpecs INNER JOIN tblSummarySheet ON tblHardwareSpecs.HardwareID = tblSummarySheet.HardwareID) " & _
    "WHERE tblHardwareSpecs.JobNumber LIKE '" & stJobnumPreFix & "' AND tblHardwareSpecs.Batched = TRUE " & _
    "ORDER BY tblHardwareSpecs.JobNumber ASC) " & _
    "ORDER BY BusinessName ASC, ORDER BY JobNumber ASC;"

    I'd be grateful for any help I can get on this. Looking at it's not obvious to me what the problem is with the joins operations.

    Thanks in advance.

    Rob

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you need to alias your subquery

    your subquery can only return one field - clientID

    and you can only have one order by in your main query

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

Similar Threads

  1. **Need help on Join Syntax error**
    By pradeepkumar089 in forum Queries
    Replies: 3
    Last Post: 12-23-2015, 11:55 PM
  2. Operation must use an updatable query-- error
    By bhushan98 in forum Queries
    Replies: 2
    Last Post: 12-01-2012, 11:32 AM
  3. Pass form values to SQL JOIN operation?
    By jonman03 in forum Queries
    Replies: 3
    Last Post: 03-06-2012, 04:59 PM
  4. Help Understanding Join Syntax In Access
    By zephaneas in forum Queries
    Replies: 5
    Last Post: 06-22-2011, 08:32 PM
  5. Replies: 2
    Last Post: 06-13-2011, 06:04 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
  •  
Other Forums: Microsoft Office Forums