Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Location
    Blackstone, MA, USA
    Posts
    5

    Unanswered: MS Access 2003 VBA SQL Error in From clause

    Hello, I'm trying to execute the following SQL statment in my VBA code and am getting a "Syntax error in the FROM clause" error message. Does it have to do with the JOIN portion?
    Code:
    mySQL = "SELECT distinct Division from tblDivisionLOBs" & _
    "FROM tblDivisionLOBs" & _
    "INNER JOIN tblUnbilled_PreCutoff_AllData_Temp ON tblDivisionLOBs.LOB = tblUnbilled_PreCutoff_AllData_Temp.LOB" & _
    "GROUP BY tblDivisionLOBs.DIVISION;"
    Any help would sincerely be appreciated

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    best thing to do in such circumstances is to examine the actual SQL, is the value of mySQL.
    whether you do that as a break point or message box is up to you. as SQL can be quite long you'd probably be better off using a debug breakpoint.

    this sort of error is usally either punctuation ie an unmatched ' or " or as it is in this statement a missing space

    mySQL = "SELECT distinct Division from tblDivisionLOBs" & _
    " FROM tblDivisionLOBs" & _
    " INNER JOIN tblUnbilled_PreCutoff_AllData_Temp ON tblDivisionLOBs.LOB = tblUnbilled_PreCutoff_AllData_Temp.LOB" & _
    " GROUP BY tblDivisionLOBs.DIVISION;"

    sometimes its stylistic but I prefer to see a space at the start of the line as its easy to check.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2012
    Location
    Blackstone, MA, USA
    Posts
    5
    Thanks foro the advice. As often the case, it's a little thing that makes a difference. I hadn't noticed that there were TWO from clauses. Thanks again for the help!

Tags for this Thread

Posting Permissions

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