I have a list box that is filled with employees names. I want the user to be able to select their name and be prompted for a password that is specific for them. I only have the list box at this point so any help will be appreciated.
Listboxes on userforms have change events. Right-click the listbox in design mode and go View Code. Select your listbox from the left-hand drop-down and Change from the right-hand one.
This will generate the skeleton code for your listbox's change event. Now you have to think of a way of checking passwords and write the code to do that.
Incidentally, are you aware that Environ("username") will return the username currently logged in? If it's suitable for your purposes, rather than ask the user to select his name from a listbox, you might consider just checking that instead. He would have had to get through the Windows login so he would have supplied a password at that point.
Great thank you for the help. The user will not be the same as the "user name" logged in. The program will be running in a guest account. Now I just need to figure out how to write the code to specify a password for each name on the list and have it ask for their password when they select it to clock in. When the enter the correct password I want a time stamp put in a specific place for payroll purposes.
Do you intend to allocate a password for each of the entries in the listbox?
If so, you could keep them in the worksheet column next to the entries which you used to load the listbox, then use VLOOKUP to retrieve the password for the selected listbox value and compare it to what the user types in.
The worksheet containing the passwords should have its visibility set to xlVeryHidden to keep it safe from prying eyes.