LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default ODBC connection question

I have 2 questions on ODBC connection.
First, is it possible to use VBA to setup the ODBC connection to link to an
access db located on each person local directory (same directory for all
users). If so, can I get some example.
Second, assuming that it is not possible, I setup a File DSN called "mydsn"
and use the following code to connect.

connstring = "ODBC;DSN=mydsn;UID=;PWD=;Database=mydatabase"
With ActiveSheet.QueryTables.Add(Connection:=connstring ,
Destination:=Range("A1"), Sql:=sqlstring)
.Refresh
End With

Everytime I run the macro, a dialog box appears asking me to "Select a data
source", then I select the "File data Source" tab to find my "mydsn". Then
another screen appears with ODBC Microsoft Access setup which shows the path
to the local directory.
Anyway to bypass these screens? I just want the user to click on "Import"
and the macro will connect to Access and import the data into cell A1.

Thanks in advance
Mat
 
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 connection failed. Jim Moberg Excel Discussion (Misc queries) 0 October 9th 06 03:51 PM
ODBC connection failed. Jim Moberg Excel Discussion (Misc queries) 0 October 9th 06 03:48 PM
ODBC Connection Adrian T[_4_] Excel Programming 4 January 25th 05 08:55 PM
ODBC connection by udl Dorothy[_4_] Excel Programming 1 January 8th 04 05:32 PM
ODBC System DSN Connection Mark[_22_] Excel Programming 4 October 21st 03 10:12 AM


All times are GMT +1. The time now is 12:56 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"