ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using ADO to Excel with this Query will not work? (https://www.excelbanter.com/excel-programming/407459-using-ado-excel-query-will-not-work.html)

todtown

Using ADO to Excel with this Query will not work?
 
I'm using ADO inside Excel to get data from another Excel workbook.

Using either the ODBC Driver for Excel or the OLE DB for Jet, I can do
this with success:

sql = "SELECT * FROM Sheet1$ WHERE F7 = 'Value'"

rs.Open sql, cn

I can use this sql, too:

sql = "SELECT * FROM Sheet1$ WHERE F7 = 'Value' AND F16 LIKE '%Value
%'"

But when I try to sum like this:

sql = "SELECT SUM(F10) FROM Sheet1$ WHERE F7 = 'Value' AND F16 LIKE
'%Value%'"

I get Null.

What should I do?

tod






Tim Williams

Using ADO to Excel with this Query will not work?
 
F10 is definitely numeric ?

Can you show the next couple of lines where you're accessing the resultset ?

Tim


"todtown" wrote in message
...
I'm using ADO inside Excel to get data from another Excel workbook.

Using either the ODBC Driver for Excel or the OLE DB for Jet, I can do
this with success:

sql = "SELECT * FROM Sheet1$ WHERE F7 = 'Value'"

rs.Open sql, cn

I can use this sql, too:

sql = "SELECT * FROM Sheet1$ WHERE F7 = 'Value' AND F16 LIKE '%Value
%'"

But when I try to sum like this:

sql = "SELECT SUM(F10) FROM Sheet1$ WHERE F7 = 'Value' AND F16 LIKE
'%Value%'"

I get Null.

What should I do?

tod









All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com