Storing a user name and password

N

Nigel

I am trying to connect to an odbc datasource by using the
transferdatabase method. If I store the user id and
password in the connection string it will work fine,
whaat I want to happen though is for the user to enter
there password on a form and have that passed to the
string, the statement I have is this

dim user,pass as string
user=me!userid
pass=me!password

DoCmd.TransferDatabase acLink, "ODBC
Database", "ODBC;DSN=olympic;UID=user;PWD=pass",
acTable, "DWPRECONV.CHARTMAP", "DWPRECONV_CHARTMAP"

it tells me that the user user does not exist, how do I
refer to the variable in the transferdatabase statement

Thanks

Nigel
 
G

Guest

I man aged to solve the issue and here is the corrected
statement

DoCmd.TransferDatabase acLink, "ODBC
Database", "ODBC;DSN=" & odbcname1 & ";UID=" & user
& ";PWD=" & pass,
acTable, "DWPRECONV.CHARTMAP", "DWPRECONV_CHARTMAP"

thanks
 
B

Bruce M. Thompson

dim user,pass as string

'You must type each variable explicitly
Dim user As String, pass As String
user=me!userid
pass=me!password

DoCmd.TransferDatabase acLink, "ODBC
Database", "ODBC;DSN=olympic;UID=user;PWD=pass",
acTable, "DWPRECONV.CHARTMAP", "DWPRECONV_CHARTMAP"

You need to move the variables to the outside of the quotes. Try:

Database", "ODBC;DSN=olympic;UID=" & user & ";PWD=" & pass,
acTable, "DWPRECONV.CHARTMAP", "DWPRECONV_CHARTMAP"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top