Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Using Add Method of QueryTables gives error

Hi All
I am trying to create a QueryTable using Add Method but it is giving

Run-Time Error "458": Variable uses an automation type that is not supported in Visual Basi
the code is given belo

direc = Worksheets("QUERY_BUILDER").Range("BH1").value 'BH1 is the database pat
datab = Worksheets("QUERY_BUILDER").Range("BH2").value 'BH2 is the database nam
Dim connstring(), sqlstring() As Varian
sqlstring = Array("SELECT DISTINCT " & field & " FROM `" & datab & "`." & table_name & " " & table_name

connstring = Array(Array("ODBC;DSN=MS Access Database;DBQ=" & datab & ";DefaultDir=" & direc & ";DriverId=25;"
), Array("FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;")

With ActiveSheet.QueryTables.Add(Connection:=connstring , Destination:=Range("AR1"), Sql:=sqlstring
.Refres
End Wit

It gives error on lin
With ActiveSheet.QueryTables.Add(Connection:=connstring , Destination:=Range("AR1"), Sql:=sqlstring

Please tell me what am I doing wrong
TI
Shilp


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Using Add Method of QueryTables gives error

Shilps

I don't know for sure, but I would try

connstring = Array(Array("ODBC;DSN=MS Access Database;DBQ=" & datab &

";DefaultDir=" & direc & ";DriverId=25;" _
), Array("FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"))


connstring=Array(Array("ODBC;DSN=MS Access Database; DBQ=" & _
direc & "\" & datab & "Default....

Maybe you need the path in the DBQ argument


--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


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
PasteSpecial Method Error PW11111 Excel Discussion (Misc queries) 1 December 19th 06 01:24 PM
ActiveSheet.QueryTables.Add using a File DSN Brian Howenstein Excel Programming 1 April 6th 04 11:45 AM
With ActiveSheet.QueryTables.Add [email protected] Excel Programming 4 January 6th 04 04:58 PM
QueryTables Interrupt if URL is Down Steve Hieb Excel Programming 0 November 17th 03 10:07 PM


All times are GMT +1. The time now is 08:15 AM.

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"