ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with .Background Query option of ODBC Query (https://www.excelbanter.com/excel-programming/295501-problem-background-query-option-odbc-query.html)

Shilps

Problem with .Background Query option of ODBC Query
 
Hi,

I have an ODBC Query in VB. Its running fine for all the tables of the database but for one table it always gives general ODBC error on
.Refresh BackgroundQuery:=Fals

the code is
With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y(
"ODBC;DSN=MS Access Database;DBQ=" + CStr(datab) + ";DefaultDir=" + CStr(direc) + ";DriverId=25;"
), Array("FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;")), Destination:=
Range("AR1")
.Sql = Array(
"SELECT DISTINCT " + CStr(field) + "" & Chr(13) & "" & Chr(10) & "FROM `" + CStr(datab) + "`." + CStr(table_name) + " " + CStr(table_name) + ""

FieldNames = Tru
.RefreshStyle = xlInsertDeleteCell
.RowNumbers = Fals
.FillAdjacentFormulas = Fals
.RefreshOnFileOpen = Fals
.HasAutoFormat = Tru
.BackgroundQuery = Tru
.TablesOnlyFromHTML = Tru
.Refresh BackgroundQuery:=Fals
.SavePassword = Tru
.SaveData = Tru

TI
Shilps


All times are GMT +1. The time now is 06:44 AM.

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