G
Guest
How do I pass a variable into the WHERE Clause of a SELECT Statement? I have the follwoing line of code
.Open "SELECT * FROM ScratchTable WHERE Stock_Sym = 'FetchStr'", connFCY, adOpenKeyset, adLockOptimistic
All of this works correctly, except the variable FetchStr, which resolves to a stock symbol, isn't getting passed correctly. Enclosed in single quotes, as above, makes the variable treated as a literal (the WHERE looks for FetchStr in the Stock_Sym field rather than looking for the stock symbol contained in the variable FetchStr). Without the single quotes, and I get a missing parameter error
Any help would be much appreciated
Eric Hines
.Open "SELECT * FROM ScratchTable WHERE Stock_Sym = 'FetchStr'", connFCY, adOpenKeyset, adLockOptimistic
All of this works correctly, except the variable FetchStr, which resolves to a stock symbol, isn't getting passed correctly. Enclosed in single quotes, as above, makes the variable treated as a literal (the WHERE looks for FetchStr in the Stock_Sym field rather than looking for the stock symbol contained in the variable FetchStr). Without the single quotes, and I get a missing parameter error
Any help would be much appreciated
Eric Hines