General ODBC Error

S

Sharlene England

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(Array( _
"ODBC;DSN=dBASE
Files;DefaultDir=C:\;DriverId=533;MaxBufferSize=2048;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
 

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