Skip to content
Advertisement

Can’t do Multiple Left Joins SQL Select (ODBC)

When I run the following SQL select statement with two left joins:

I get the following error message in Excel VBA:

“Run-time error ‘5’: Invalid procedure call or argument”

vba error

When I run that exact same SQL without the left joins, it works without issue.

I know the first SQL statement above is valid because it works just fine (joins-included) when I import it through ODBC in the Excel “get data from other sources” tool:

enter image description here

Do you know what I am doing wrong here? My goal is to run the original Select statement in VBA and have the results populated in a table object. I have done this before countless times but I guess I have not done it with two left joins in the SQL.

Just for grins, here is my code:

#################################################################################

Thank you!

Advertisement

Answer

The answer is very simple.

Per Tim Williams, all I had to do was just remove the Array() from the .CommandText line and that fixed it.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement