General Odbc Error 1004 Excel
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn
General Odbc Error Excel 2013
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags run time error 1004 general odbc error Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, runtime error 1004 general odbc error helping each other. Join them; it only takes a minute: Sign up Excel 2007 - 1004 Run-time error Refresh Query Table up vote 1 down vote favorite It appears that this error is so generic that many
Run Time Error 1004 General Odbc Error Refresh Backgroundquery False
of the existing solutions address different issues. In my case I have created a macro that works in Excel 2010 and does not work in Excel 2007. Here is a summary of the code: cn = "ODBC;Driver={SQL Server Native Client 10.0};Server=serverName;Database=dbName;Trusted_Connection=yes;" sql = "select top 10 * from tableName" Dim S As Worksheet Set S = ActiveWorkbook.Sheets("Medical") With S.QueryTables.Add(Connection:=cn, Destination:=S.Range("B1")) .CommandText = sql .Refresh BackgroundQuery:=False End With This code executes perfectly in Excel 2010, but errors
Error 1004 Excel Vba
out in Excel 2007. Do I need to change the connection string structure for 2007, or is there another issue at work? excel vba odbc runtime share|improve this question edited May 6 '13 at 22:06 Undo♦ 18.4k157399 asked Apr 22 '13 at 16:03 lance 26115 Error 1004 is generic error but do you have the actual error text? Should say something like Runtime error 1004: followed by more description - that will help narrow down the problem. –AxGryndr Apr 22 '13 at 16:20 Run-time error '1004': General ODBC Error –lance Apr 22 '13 at 16:39 Is there a query in range B1 of the Medical sheet? If you right click in the cell you should see the refresh option. –AxGryndr Apr 22 '13 at 16:54 It does in 2010, but not in 2007. –lance Apr 22 '13 at 17:35 Instead of .Commandtext can you try changing S.QueryTables.Add(Connection:=cn, Destination:=S.Range("B1")) to S.QueryTables.Add(Connection:=cn, Destination:=S.Range("B1"), Sql:=sql)? –AxGryndr Apr 22 '13 at 17:51 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote accepted Solution: All machines I was using with Excel 2010 have "SQL Server Native Client 10.0" as a possible driver for ODBC Data Sources. The machines with Excel 2007 only have "SQL Server". I changed my connection string to be: cn = "ODBC;Driver=SQL Server;Server=serverName;Database=dbN
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the error 1004 excel macro workings and policies of this site About Us Learn more about Stack
Visual Basic Error 1004 Excel
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs general odbc error refresh backgroundquery Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; http://stackoverflow.com/questions/16151560/excel-2007-1004-run-time-error-refresh-query-table it only takes a minute: Sign up Excel 2010: Run time error 1004 general odbc error up vote 0 down vote favorite I have a small Excel 2010 query that either times out (not responding) then gets the error Run time error 1004 general odbc error When I debug it highlights this line: Selection.QueryTable.Refresh BackgroundQuery:=False This was working in http://stackoverflow.com/questions/28296258/excel-2010-run-time-error-1004-general-odbc-error Excel 2007. I tried On Error Resume Next to get the query to skip any errors and move to the next part but that didn't help. Sub Refresh_all() Application.ScreenUpdating = False Application.Goto Reference:="querycell" Range("A2").Select Selection.QueryTable.Refresh BackgroundQuery:=False Dim pt As PivotTable Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables pt.RefreshTable Next pt Next ws Application.Goto Reference:="returncell" Range("A1").Select Application.ScreenUpdating = True End Sub excel excel-vba excel-2010 share|improve this question edited Mar 18 '15 at 8:31 asked Feb 3 '15 at 10:10 Matt 7,549154482 Which line do you receive the error on? –Gareth Feb 3 '15 at 10:32 @Gareth ill try and get it to error again, but mostly it just times out (excel not responding). is there any syntax that isn't compatible in 2010? –Matt Feb 3 '15 at 10:46 Is it still timing out even if you remove the On Error Resume Next statement? Apart from that are you sure you are wanting to refer to the ActiveWorkbook rather than ThisWorkbook? –Gareth Feb 3 '15 at
Forums Excel Questions General ODBC Error - Run time error 1004 Results 1 to 10 of 10 General http://www.mrexcel.com/forum/excel-questions/433755-general-odbc-error-run-time-error-1004-a.html ODBC Error - Run time error 1004This is a discussion on General ODBC Error - Run time error 1004 within the Excel Questions forums, part of the Question Forums category; Please help me before this laptop becomes a Frisbee! I almost have this working but I'm getting stuck on this ... LinkBack LinkBack URL error 1004 About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Dec 3rd, 2009,12:58 PM #1 John Wood Board Regular Join Date Sep 2008 Location Ontario, Canada Posts 118 General ODBC Error - general odbc error Run time error 1004 Please help me before this laptop becomes a Frisbee! I almost have this working but I'm getting stuck on this error every time I execute it. I have an ODBC with read-only privileges and I recorded part of the code from the macro. The "from" and "to" date fields I added ( I think I'm correct). I would truly appreciate the help. Here's the code: Private Sub CommandButton1_Click() Dim smpldatea As Date Dim smpldateb As Date Dim fdate1 As String Dim fdate2 As String smpldatea = UserForm1.TextBox1.Text smpldateb = UserForm1.TextBox2.Text fdate1 = Format(smpldatea, "m/d/yyyy hh:mm:ss") fdate2 = Format(smpldateb, "m/d/yyyy hh:mm:ss") Sheets("Sheet1").Activate Range("A1:H10000").ClearContents With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _ "ODBC;DRIVER={Oracle in OraHome92};SERVER=XXXXXX;UID=DT_I;PWD=RO2ACCESS;DBQ=XXXXXXP;DBA=W;APA=T;EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10" _ ), Array( _ ";FDL=10;LOB=T;RST=T;GDE=F;FRL=Lo;BAM=IfAllSuccessful;MTS=F;MDI=Me;CSR=F;FWC=F;PFC=10;TLO=O;" _ )), Destination:=Range("A1")) .CommandText = Array( _ "SELECT DT_CENTERLINE_AUDIT.AUDIT_DATE, DT_CENTERLINE_AUDIT.CENTERLINE_ID, DT_CENTERLINE_AUDIT.COMPLIANT, DT_CENTERLINE_AUDIT.CORRECTED, DT_CENTERLINE_AUDIT.LINE, DT_CENTERLINE_AUDIT.LOCATION" & Chr(13) & "" & Chr(10) & "FROM DTD" _ , _ "BA.DT_CENTERLINE_AUDIT DT_CENTERLINE_AUDIT" & Chr(13) & "" & Chr(10) & "WHERE (DT_CENTERLINE_AUDIT.AUDIT_DATE>= '" & fdate1 & "' And DT_CENTERLINE_AUDIT.AUDIT_D