1

I can get this query to run if I remove the Join, but once I add the join, I get the following error:

Run-Time error '3135': Syntax error in Join Operation

sourceDB = "C:\sourcedb.accdb"

SQL = "SELECT e1.lid " & _
        "FROM (eventlog e1 IN  '" & sourceDB & "'" & _
        "LEFT JOIN eventlog e2 ON e2.lid = e1.lid)"

Any advice on what I might be doing wrong

1
  • Try as e1 and as e2. As far as I know, MS Access requires the as for table aliases. Commented May 31, 2015 at 23:16

2 Answers 2

2

Try changing your code to the following:

sourceDB = "C:\sourcedb.accdb"

SQL = "SELECT e1.lid " & _
      "FROM [" & sourceDB & "].[eventlog] AS e1 " & _
      "LEFT JOIN eventlog AS e2 ON e2.lid = e1.lid"
Sign up to request clarification or add additional context in comments.

1 Comment

That was the answer I was looking. I had my join all wrong.
0

You have an obvious syntax error in your query: the join must be between two Tables, not the Table and Database name. Take a look at this canonical example (re: https://msdn.microsoft.com/en-us/library/office/ff198084.aspx) and correct your query correspondingly:

SELECT CategoryName, ProductName FROM Categories LEFT JOIN Products 
ON Categories.CategoryID = Products.CategoryID;

Hope this will help. Best regards,

3 Comments

That makes sense, but the join is between eventlog 1 and eventlog2. Unless the IN statement is the wrong part?
And my IN stament was in the wrong spot. Thanks for the help.
I have extended the answer. If you are satisfied with the answer please mark it accepted. Good luck with your project. Best regards,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.