A user selects a single item in a listbox. With the code below, I am failing at deselecting the line the user selected.
This isn't deselecting the user's selection.Please Login or Register to view this content.
A user selects a single item in a listbox. With the code below, I am failing at deselecting the line the user selected.
This isn't deselecting the user's selection.Please Login or Register to view this content.
Is multi-select set to TRUE? If not, replace your For loop with this one line:
Please Login or Register to view this content.
Hi Jeff, thanks so much for you help.
It isn't multiselect, so I replaced the loop with the line you suggested.
But I'm experiencing an odd thing as a result that I can't resolve.
The user selects an item from the list, empl_no = 0 so the message box displays. The user hits OK in the msgbox, and the message box displays again. The user hits OK again but the selection remains in the listbox.
Clearly something wrong with my code or my approach.
I forgot about one thing. When your code changes the listbox.listindex, it acts like a click, and the Sub is called again automatically.
The textbook way to manage this is to use a variable to indicate whether events are to be processed. It looks like you already have such a variable, mbevents.
Please Login or Register to view this content.
Thanks Jeff for the suggestion. I have implemented it but experiencing the same problem.
I've put a break at the top of the code to follow the events ..
Follow the results of the steps ...
empl_no tests true for equalling 0
Message box displays
mbevents value = false
The selection remains highlighted in the listbox with lb_ssr.listindex = -1
mbevents reset to true
exit sub
code goes back up to the first line ... Private Sub lb_ssr_Click() line.
Code repeats itself ...
empl_no tests true for equalling 0
Message box displays
mbevents value = false
The selection remains highlighted in the listbox with lb_ssr.listindex = -1
mbevents reset to true
exit sub
The routine exits at this point.
Unsure why it is repeating.
I would be happy to test this in your file if you attach it.
Hey Jeff, that's such a kind offer.
Here is the link for the download. I use winrar, so it's in a .rar archive despite my attempts to make a .zip file. I hope this doesn't cause grief.
To recreate.
Place both files in a folder together. You will encounter errors as the code refers to my local file locations.
Open StaffSched_ef.xlsm first. It will automatically open the second supportiung workbook and hiding it.
Click the blue oval on worksheet "STAFF_FRONT". This opens a userform.
Select one of the names in the "name" combobox. They all behave the same way.
Puch button [View/Modify Employee Schedule]
Select a pay period from the "Pay Period Combobox". I recommend choosing from between periods 11 and 17.
The listbox (lb_ssr) will populate.
Click on one of the rows in the listbox and ...
You should experience the problem.
Thanks again!
Last edited by Jenn68; 03-22-2019 at 07:12 AM.
I don't have anything that opens a rar file.
Try this ... its a zip file.
Last edited by Jenn68; 03-22-2019 at 07:12 AM.
I get errors all over the place no matter how I try to run this. I'll see if I can strip out the relevant code and isolate the problem.
Can I assume that no one was able to find a solution?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks