excel dates in sql procedures

R

ragup001

I am still getting sql syntax error.

Here is my procedure:

Sub ABC()
Dim qt As QueryTable
Dim a As String
Dim b As String

Sheets("abc").Select
a = Range("a1").Text
b = Range("a2").Text

sqlstring = "exec emputilization " & a & "," & b

"ODBC;DSN=empdata;UID=;PWD=;Database=empdata"

Sheets("Temp").Select
With ActiveSheet.QueryTables.Add( _
Connection:=connstring, _
Destination:=Range("A1"), Sql:=sqlstring)

..Refresh

End With


End Sub


Sheet "abc" : A1 is the startdate 1/1/2007 and A2 is the enddate 1/31/2007


Any help is appreciated.

Thanks,

ragup
 
B

Bob Phillips

Just a suggsetion. Try

sqlstring = "exec emputilization " & _
Format(Range("A1").Value, "\#dd mmmm yyyy\#") & "," & _
Format(Range("B1").Value, "\#dd mmmm yyyy\#")

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top