Question:
Sorry for what is a probably a dumb question and the generic title. However, I have been trying to feed in values from my login user form into the main module code that generates a sql query that will pull data from our general ledger straight into excel.In order to mask the password as it is typed I set up a very simple user form that has two text boxes (username and password) a login command button and a cancel button. I then some checks to the login click command checking the user details fields are not empty (there is further code in the download request that will validate if the user name is correct based on the response from the server).
Whist I can’t get through is on my main module that feeds the class that will generate the query string, to pick up the items that are fed into the user form. I have tested with hardcoded login details so I know the code works. I have included below the portion of my user form that relates to the login click and the general module portions around this user form call and then the updating of the class module. the main module is triggered by a button click on the worksheet.
user form snippet
Answer:
In order to make your 2 module level variables available to the userform declare them asPublic
instead of using Dim
:Rather than using globals/public variables which is generally bad practice you can use a dialog based approach to return the data.
Create a Type in the module to store the user details:
If you have better answer, please add a comment about this, thank you!