• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: why can’t i pass userform values into general module

Resolved: why can’t i pass userform values into general module

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

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
main module snippets

Answer:

In order to make your 2 module level variables available to the userform declare them as Public instead of using Dim:
You need to delete the identically named variables:
from your userform as these local variables will shadow the public ones.
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:
Add an exit button & change the userform to:
Then in the module you can fetch the details:

If you have better answer, please add a comment about this, thank you!

excel vba
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Getting ‘502 Bad Gateway’ while deploying Springboot app in EKS

24/03/2023

Resolved: Why is NGINX’s $request_uri empty?

24/03/2023

Resolved: How to convert Java bytecode to Webassembly using CheerpJ compiler

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.