ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   General ODBC Error (https://www.excelbanter.com/excel-programming/409360-general-odbc-error.html)

Sharlene England[_2_]

General ODBC Error
 
I am running a VBA macro as the following statements:
When it gets to the RefreshBackgroundQuery line, I get a
Run-time error 1004 and a General ODBC Error.

This works on several machines and several users, and on other users I get
the above mentioned error. This is not a problem with the code, but must be
a setting in the persons excel options or something on their individual
machine. Also, when I run this on my own machine it works, but if I log
into terminal server I get the error.

Any help would be greatly appreciated!!

With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=dBASE
Files;DefaultDir=C:\;DriverId=533;MaxBufferSize=20 48;PageTimeout=" _
), Array("5;")), Destination:=Range("A1"))
.CommandText = Array( _
"SELECT JOB_NO, DATE, EMPCODE, CODE, CLASS, HOURS, TYPE FROM
K:\DATA\TIMEDATA\DB2K\TIMESKEL.DBF " _
& "TIMESKEL WHERE([JOB_NO]=" & Range("jobnumber").Value _
& "AND [DATE]=#" & Range("entereddate").Value & "# AND [TYPE]<'3' )"
_
)
.Name = "Query from dBASE Files"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False 'changed to make refresh work
.BackgroundQuery = False 'removed January 2006
.RefreshStyle = xlOverwriteCells
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False 'removed January 2006
End With




All times are GMT +1. The time now is 02:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com