Help! Error 1004

D

Doctorcpu

Hi,

I'm trying to retrieve records from a SQL Server but continue to get ERROR
1004. I used the wizard as much as possible to create the following. I need
help with the syntax for Excel 2003.

Any help is appreciated

With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DRIVER=SQL Native
Client;SERVER=LRD1CA99;UID=weholt;Trusted_Connection=Yes;APP=Microsoft Office
2003;WSID=HOLT-WESLEY-E;DATABASE" _
), Array("=AHD;")), Destination:=Range("L39"))
.CommandText = Array( _
"SELECT Top 25 pc.sym AS RequestArea, COUNT(*) As RATotal" & Chr(13)
& "" & Chr(10) & "From AHD.call_req cr INNER JOIN AHD.prob_ctg pc ON
pc.persid=cr.category" & Chr(13) & "" & Chr(10) & "WHERE
(call_req.zInitDtTm>=" & startDate & " And call_req.zInitDtTm<=" & endDate &
") GROUP BY pc.sym ORDER BY RATotal DESC" _
)
.Name = "Query from test1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
 

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