variable for userid and password for passthrough

joemeshuggah

Board Regular
Joined
Jul 18, 2008
Messages
161
i have an access database set up to run a number of passthrough queries via macro. to avoid having to constantly enter user ID and password, i set up the ODBC Connect Str in the property sheet of each passthrough query to include my user ID and password.

this works fine, but when it comes time to update my password, i ultimately have to go into each passthrough property sheet and update the connection string with my new password. i was hoping to get around this by using a variable...so i entered the following into the ODBC Connect Str box in the property sheet of each passthrough:

ODBC;DSN=MyDataBase;UID=StrUser;PWD=StrPass;DATABASE=MyDataBase;

i then created a form with a button that has the following for the even procedure

Private Sub cmdRunMacro_Click()
Dim StrUser As String
Dim StrPass As String
StrUser = InputBox("Enter User ID")
StrPass = InputBox("Enter Password")

DoCmd.RunMacro "DataBaseUpdate"
End Sub

the connection fails...is there something i am missing?

oddly, if change just one of the passthrough connection strings to include my actual user id and password, run it, then change it back to the variable strings & re-run the macro, the macro completes successfully.
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Watch MrExcel Video

Forum statistics

Threads
1,122,518
Messages
5,596,631
Members
414,082
Latest member
sasmita

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top