I am using SQL statements in VBA and I am having trouble joining 4 tables located in separate worksheets named "Stn", "Db", "Param" and "Ol"
I have 4 tables:
The final table I want is : Station_abbreviation, parameter_abbreviation, Sample_date, Concentration and Flag
Not all the data have Flags, so I want to use an outer join and have it return all data even the ones without a "flag"
However I get this error "syntex error in FROM clause"
Help would be appreciated!
I have 4 tables:
- "Stn" with headers: Station_Name, Station_Abbreviation, Station_Order
- "Db" with headers: Station_Name, Sample_Date, Parameter_Name, Concentration
- "Param" with headers: Parameter_Name, Parameter_Abbreviation
- "OL" with headers: Station_Abbreviation, Sample_Date, Parameter_abbreviation, Concentration and Flag
The final table I want is : Station_abbreviation, parameter_abbreviation, Sample_date, Concentration and Flag
Not all the data have Flags, so I want to use an outer join and have it return all data even the ones without a "flag"
Code:
strSourceSht = "[db$]"
strParamSht = "[param$]"
strStnSht = "[stn$]"
strOutlierList = "[OL$]"
strSQLtest = "SELECT s.Station_Abb, p.Parameter_Abb, db.Sample_Date, db.Concn, ol.Status" & _
" FROM ((" & strSourceSht & " AS db" & _
" INNER JOIN " & strStnSht & " AS s" & _
" ON db.Station_Name = s.Station_Name)" & _
" INNER JOIN " & strParamSht & " AS p" & _
" ON db.Parameter_Name = p.Parameter_Name) " & _
" LEFT JOIN " & strOutlierList & " AS ol" & _
" ON db.Concn = ol.Concn)
However I get this error "syntex error in FROM clause"
Help would be appreciated!