View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
shilps shilps is offline
external usenet poster
 
Posts: 1
Default Problem in ODBC Query


Hi,
I have a code as given below:
With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y("ODBC;DSN=M
Access Database;DBQ=" + CStr(datab) + ";DefaultDir=" + CStr(direc) _
+ ";DriverId=25;"), Array("FIL=M
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 = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = False

Actually the result of this query is stored in column AR and table nam
is the option selected from the ComboBox. The problem is that for al
but few options in the ComboBox, this query runs fine. But for fe
options , it gives error on line

.Refresh BackgroundQuery:=False

The options in the ComboBox are the names of the field names. Th
problem occurs only when I try to pick the data from the a particula
table while it works fine with other tables. This table was added t
the database at a later point but this should not be a cause of thi
problem, or cud it be?


Any idea why?
TIH
Shilp


-
shilp
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message587856.htm