Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Problem in ODBC Query

Try enclosing the table name with square brackets. These are unnecessary for names that do not have an embedded space but mandatory when they do.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC Query Laddie Excel Worksheet Functions 0 April 23rd 10 03:35 PM
ODBC query problem Arvi Laanemets Excel Discussion (Misc queries) 3 September 26th 08 02:03 PM
MS Query/ODBC/SQL problem Jen Excel Discussion (Misc queries) 0 December 3rd 04 03:11 PM
Problem with ODBC Query Shilps Excel Programming 2 April 20th 04 05:46 AM
Problem with .Background Query option of ODBC Query Shilps Excel Programming 0 April 19th 04 06:41 AM


All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"