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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a database that needs to obt

Status
Not open for further replies.

DPUser

Technical User
Oct 17, 2003
16
US
I have a database that needs to obtain its data from another database through an ODBC. I am using transferdatabase to obtain the linked tables. I want to be able to have the user enter the user id and password. How can I substitute a string variable in the place where user id goes?
My code is as follows:


Dim datsource1 As String
Dim cnn1 As New ADODB.Connection
Dim rst1 As ADODB.Recordset
DataSource.SetFocus
datasource1 = DataSource.Text

DoCmd.TransferDatabase acLink, "ODBC Database", "ODBC;DSN=datasource & ";UID=icstpass;PWD=ictspass;DATABASE=stamprod_sql", acTable, "exch_tools_trade", "dbo_exch_tools_trade"

Thank you
 
Try an input box

DoCmd.TransferDatabase acLink, "ODBC Database", "ODBC;DSN=datasource & ";UID='" & inputbox("Please enter userID") & "';PWD='" & inputBox("Please enter password") & "';DATABASE=stamprod_sql", acTable, "exch_tools_trade", "dbo_exch_tools_trade"

I've never tried or tested it but I see no reason why it should not work

Savil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top