Reputation: 1
I am building SQL queries in VBA, and the following returns an error:
stSQLstring = "SELECT * FROM [" & sheetName & "$]
WHERE [" & headerName & "] in (" & stNodes & ");"
Debug.Print stSQLstring gives:
SELECT * FROM [sheetName$]
WHERE [headerName] in ('3','4','5','6','16','45','64','65','67','71','76','79','80','86','89','103','115','116','124','142','145','160');
I am then using ACE.OLEDB to query an external workbook (I think this part is fine as it works with other SQL statements, just not this one).
I would be really grateful for you help!
Upvotes: 0
Views: 505
Reputation:
You shouldn't use the single quotes when working with numbers.
SELECT * FROM [sheetName$] WHERE [headerName] in (3,4,5,6,16,45,64,65,67,71,76,79,80,86,89,103,115,116,124,142,145,160);
Upvotes: 1