Excel vba query not working, pls help me.
Hi
When i try to use the query "SELECT name, num FROM [Sheet2$] WHERE ((name IN ('A', 'C')) AND (num IN ('2')))" in excel 2000 vba i'm getting the Runtime error -'-2147217913 (80040e07) Pls help me.
The table is
name num code1 code2
A 1 aa 5
B 1 bb 6
A 2 aa 5
C 1 cc 7
D 3 dd 7
A 1 aa 6
B 2 bb 5
B 2 bb 5
The code is
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=D:\Kavitha\CM\NPI\Scorecard\TESTFILTER.xls; " & _
"Extended Properties=Excel 8.0;"
.Open
End With
strQuery = "SELECT name, num FROM [Sheet2$] WHERE name IN ('A', 'C') AND num IN ('2')"
rs.Open strQuery, cn, 2
The above query is working well in sql query analyser , but not in excel vba. pls help me to solve this issue.
Thanks a lot
Kavitha
|