View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default SQL Database Query


You don't say how you are trying to retrieve this data, but since this
is a programming forum I'll assume you're trying to use VBA. In that case,
you'll need to specify the SQL statement as a string in order to do anything
with it. One way to do that, which includes a demonstration of how to
collect the date from your worksheet cell, is the following:

Dim szSQL As String

szSQL = "SELECT * " & _
"FROM Table1 " & _
"WHERE (" & Sheet1.Range("A1").Value & "='07/07/2005')"

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Zinewowe" wrote in message
...
I want retreive data from Table1 from a SQL database which match the WHERE
criteria:

SELECT *
FROM Table1
WHERE (date1='07/07/2005')

date1 is a field in Excel which I use to define the date for the WHERE
criteria.

I tried the following but it did not work (I entered the date value in
field
A1 in the Excel sheet):
SELECT *
FROM Table1
WHERE ('A1'='07/07/2005')

What am I doing wrong?
Thanks