Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help on ODBC connection

Status
Not open for further replies.

3pmilk

MIS
Jun 20, 2002
46
US
Hi all,


I use access as the front-end and Oracle as the backend
I have a form that has a button; when click it, it will produce and export the result set to a excel spreadsheet.
The problem I have is that when user clicks the button, they have to manually select the datasource of the 'select data source screen' on the 'Machine Data Source' before they can see the result.

So being a novice VBA programmer, I want to code the odbc connection string in the module so that users don't have to manually select the datasource. Shown below is the code. any help would be much appreciate it.
By the way, my query is made up serveral pass-thru queries in access, so it's prompting user 2 or 3 times for the datasource before they can see the result.

Code
---------

Option Compare Database

Dim odbcConnection as new Connection

private Sub Command1_click()
Docmd.OpenQuery "Master Material Report"

Dim StrConn as String

Set odbcConnection = new Connection
StrConn = 'ODBC;DSN=a019prod;UID=priv;PWD=abc;Server=Oracle in OraHome92"
odbcConnection.connectionString = StrConn
Docmd.OutputTo acQuery, "Material Master", "MicrosoftExcel(*.xls", "C:\Mater_" & Format(Now(), "yyyymmdd" & ".xls", True, ""

set odbcConnection = Nothing

End sub



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top