M
matelot
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
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