Link to home
Start Free TrialLog in
Avatar of Jen T
Jen T

asked on

Access VBA - selected Item in Listbox (multiselect) - value of ONE item selected

hi there,

I couldn't find the answer and nothing I've tried worked so here goes.
I have a multi-select listbox on my form. I know how to go through the selected items (through a for loop) and retrieve the values of the selected items. But i have an if else statement that goes:

if items_Selected > 1 then
   do. some things
else (if item selected is 1) then
  retrieve whatever was selected  - just the one value and then do some stuff!

I can't figure out how to retrieve whatever was selected when it's just one.
Do I have to go through a loop?
I've tried: Me.lstStuff.ItemData, Me.lstStuff.ItemsSelected even Me.lstStuff.Value and nothing worked :(.

Please help and thank you.
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jen T
Jen T

ASKER

Alright. I just removed the if...else statement. I was trying to do 2 different SQL queries on whether there are 1 or more than 1 listbox items selected (for grouping with parenthesis and such), but I guess I don't need to make it more complicated by that statement. :)
Thanks guys.