I would like to prevent the ODBC Connection Dialog box from appearing when I run an Excel VBA macro that queries an ODBC database.
I am using the following code in VBA to open the connection..the query works fine and produces the output but the query box still appears whatever I try (SQL_Driver_NoPrompt etc)...but maybe I have been using it incorrectly. Any help would be much appreciated.
Sub UsingSQLOpen()
Dim Chan As Variant
Dim queryString As String
queryString = "SELECT * from Customers where CustID = 100"
Chan = sqlopen("DSN=TestDSN;UID=TestUser;PWD=Test;SERVER=TestServer;"
SQLExecQuery Chan, queryString
SQLRetrieveToFile Chan, "c:\OUTPUT.TXT", True
SQLClose (Chan)
End Sub
I am using the following code in VBA to open the connection..the query works fine and produces the output but the query box still appears whatever I try (SQL_Driver_NoPrompt etc)...but maybe I have been using it incorrectly. Any help would be much appreciated.
Sub UsingSQLOpen()
Dim Chan As Variant
Dim queryString As String
queryString = "SELECT * from Customers where CustID = 100"
Chan = sqlopen("DSN=TestDSN;UID=TestUser;PWD=Test;SERVER=TestServer;"
SQLExecQuery Chan, queryString
SQLRetrieveToFile Chan, "c:\OUTPUT.TXT", True
SQLClose (Chan)
End Sub