ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax for ADO Query String (https://www.excelbanter.com/excel-programming/320820-syntax-ado-query-string.html)

john

Syntax for ADO Query String
 
Hi,

I am trying to use ADO with an Excel spreadsheet. I have
done this successfully before, but I am having problems, I
think, because one of the fields I am using has a space in
it. (End Date). The string I am using is:

strquery = "Select * from [Sheet1$] where Property='" &
LookupP & "' and [End Date]='" & LookupEnd & "'"

Would anyone be able to tell me what I am doing wrong? I
have also tried several different ways.

THANKS!

Jamie Collins

Syntax for ADO Query String
 

John wrote:
I am trying to use ADO with an Excel spreadsheet. I have
done this successfully before, but I am having problems, I
think, because one of the fields I am using has a space in
it. (End Date). The string I am using is:

strquery = "Select * from [Sheet1$] where Property='" &
LookupP & "' and [End Date]='" & LookupEnd & "'"


What 'problems' e.g. an error message? I don't think the column name is
the problem because you've put it in brackets. Perhaps it is the value
of the LookupEnd variable e.g. is it a valid date format? Try
[End Date]='" & Format$(LookupEnd, "yyyy-mm-dd") & "';"

Jamie.

--



All times are GMT +1. The time now is 05:11 PM.

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