Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a very basic excel macro:
Sub CreateQT() On Error GoTo ErrorHandling Dim sConn As String Dim sSql As String Dim oQt As QueryTable sConn = "{SQL Native Client};" sConn = sConn & "Server=.SERVER\SQLExpress;" sConn = sConn & "AttachDbFilename=testExcel.mdf;" sConn = sConn & "Database=dbname;Trusted_Connection=Yes;" sSql = "SELECT dataField " sSql = sSql & "FROM testTable" Set oQt = ActiveSheet.QueryTables.Add(Connection:=sConn, Destination:=Range("a1"), Sql:=sSql) oQt.Refresh GoTo No_Error 'End Sub ErrorHandling: MsgBox Err.Number & " " & Err.Description No_Error: End Sub but this fails: Set oQt = ActiveSheet.QueryTables.Add(Connection:=sConn, Destination:=Range("a1"), Sql:=sSql) with a 1004 Application-define or object-defined error... How do I find/debug the couse and get the query to run? (sorry newbie in this stuff - maybe very basic question) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Uh oh...Runtime error 1004!!!! | Excel Programming | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Runtime error 1004 | Excel Programming | |||
Runtime Error 1004 | Excel Programming | |||
Runtime error '1004': | Excel Programming |