Storing a user name and password

  • Thread starter Thread starter Nigel
  • Start date Start date
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
 
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
 
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"
 
Back
Top