keep password used in connection to database till the workbook is closed

  • Hi all,


    I have some code for masking password when a macro is run to get data from a database. It works, but for each run, I have to input the password and that can be really a pain and many users complain about it.


    This is the code I have that when a user presses the button to run the macro:

    Code
    Dim uiValue As String
    uiValue = UserForm1.ValueEntered("My dear friend, please enter your secret password", "Excel Tools V.1.0", "", Chr(165))
     
    conn.Open "DSN=Data;Databasename=DatabaseName;Uid=" & login & ";Pwd=" & uiValue & ";"


    and this is the code from the userform that opens up to imput password and it also masks the password:


    The login I have in a cell that the user fill in and that stays there, but I would prefer to be able to have it in the the userfom that pops up (just no clue how to solve that)


    There are various sheets in the workbook that needs to pass also the login and password to use the macros.


    If the workbook could keep in memory the login and password till it closses, well that would be really nice.


    Greetings

  • Re: keep password used in connection to database till the workbook is closed


    This example userform stores data in the Registry

  • Re: keep password used in connection to database till the workbook is closed


    Hi,


    I will try this out and let you know if it worked out.


    Thanks a lot.


    Greetings.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!