Solved How to identify "selected" items from multivalue combobox (1 Viewer)

Local time
Today, 14:14
Joined
Feb 2, 2020
Messages
45
Hi,
At the risk of getting yelled at for asking a multivalue combobox question, I would still like to know, how does one cycle through a multivalue combobox to obtain only the records which were selected?

Combobox is called NamesList

I am using the following without success.
For Each oItem In Me!NamesList.ItemsSelected

Thank you
 

theDBguy

I’m here to help
Local time
Today, 11:14
Joined
Oct 29, 2018
Messages
10,208
Hi. I think there's an easier way by using a query with the Value column in it.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 19:14
Joined
Jul 9, 2003
Messages
11,505

Micron

AWF VIP
Local time
Today, 14:14
Joined
Oct 20, 2018
Messages
2,790
Are these fields of the checkbox type? Maybe along the lines of
Dim i as integer

For i = 0 to Me.nameOfControl.ListCount - 1
If Me.nameOfControl.Selected(i) = true then

I'm just guessing here as I don't use these either. If you want to provide a db copy we can try (I would be trying the approach I'm thinking of).
 
Local time
Today, 14:14
Joined
Feb 2, 2020
Messages
45
Hi. I think there's an easier way by using a query with the Value column in it.
Thank you. I like the idea. What do I use as criteria with the Value column to select the items selected vs those that are not?
Not Null?, True?
 

theDBguy

I’m here to help
Local time
Today, 11:14
Joined
Oct 29, 2018
Messages
10,208
Thank you. I like the idea. What do I use as criteria with the Value column to select the items selected vs those that are not?
Not Null?, True?
You would use the ID field of the record containing the MVF values for your criteria.
 
Local time
Today, 14:14
Joined
Feb 2, 2020
Messages
45
Are these fields of the checkbox type? Maybe along the lines of
Dim i as integer

For i = 0 to Me.nameOfControl.ListCount - 1
If Me.nameOfControl.Selected(i) = true then

I'm just guessing here as I don't use these either. If you want to provide a db copy we can try (I would be trying the approach I'm thinking of).
 
Local time
Today, 14:14
Joined
Feb 2, 2020
Messages
45
Thank you for your reply.

Yes, it is of the checkbox type. I believe I also attempted what you suggested but I have always found that in the statement
If Me.nameOfControl.Selected(i) , Me.nameOfControl.Selected(i) always seems to return a value of 0.
Test DB attached.
 

Attachments

Local time
Today, 14:14
Joined
Feb 2, 2020
Messages
45
You would use the ID field of the record containing the MVF values for your criteria.
If I understand correctly, then if my multivalue field has the following:
ID Name
1 John
2 Sam
3 Karen

I would have to check each ID # in the query in order to determine if I get a result?
Sorry, I am obviously not getting it.

Thanks
 
Local time
Today, 14:14
Joined
Feb 2, 2020
Messages
45
I'm not 100% sure, but I reckon it's covered in the excellent video about multi-value combo's on my website here:- https://www.niftyaccess.com/multi-value-fields-links/ and there are some excellent links which I have saved over the past few years.
Thanks for the note.
I did actually watch your video several times earlier this morning in order to come up with an answer. You do show how to use Ubound to find the first instance of a chosen record. However, I was not able, even after watching it several times, to determine how to get all the items that were selected. Maybe its just me.
 

theDBguy

I’m here to help
Local time
Today, 11:14
Joined
Oct 29, 2018
Messages
10,208
If I understand correctly, then if my multivalue field has the following:
ID Name
1 John
2 Sam
3 Karen

I would have to check each ID # in the query in order to determine if I get a result?
Sorry, I am obviously not getting it.

Thanks
Hi. If your MVF is looking up values in another table, there are two tables involved in your query. This would be the case, especially, if you're storing the ID field in your MVF. If so, your query might look something like this:

SQL:
SELECT [Name]
FROM LookupTable
WHERE ID In(SELECT MVFName.Value
FROM YourTableName
WHERE PK=ThePKValueOfTheRecordYouWant)
 
Last edited:
Local time
Today, 14:14
Joined
Feb 2, 2020
Messages
45
Hi. If your MVF is looking up values in another table, there are two tables involved in your query. This would be the case, especially, if you're storing the ID field in your MVF. If so, your query might look something like this:

SQL:
SELECT [Name]
FROM LookupTable
WHERE ID In(SELECT MVFName.Value
FROM YourTableName
WHERE PK=ThePKValueOfTheRecordYouWant)
thank you again for trying to help me. I'm still lost and I guess I'm just not getting it today. I appreciate the time you have given me and don't want to waste any more of it just because I don't get it.
 

theDBguy

I’m here to help
Local time
Today, 11:14
Joined
Oct 29, 2018
Messages
10,208
thank you again for trying to help me. I'm still lost and I guess I'm just not getting it today. I appreciate the time you have given me and don't want to waste any more of it just because I don't get it.
Hi. If you can post a demo version of your db, we can show you what we mean.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 14:14
Joined
May 21, 2018
Messages
3,154
I think this answers more your original question. You can loop it in the exact same way you loop a multi select listbox (not a multi value). The problem the way you have it, the items selected will always be empty. The reason is that until you dropdown the combobox the items are not pulled from the related table and populated, so you have to code it to dropdown first before looping the items selected.
 

Attachments

Micron

AWF VIP
Local time
Today, 14:14
Joined
Oct 20, 2018
Messages
2,790
Must be a browser issue for me - I can't download. It tries to open a new tab??

Never mind - the download happens anyway.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 19:14
Joined
Jul 9, 2003
Messages
11,505
I did actually watch your video several times earlier this morning in order to come up with an answer.
I Revisited my Blog and I realise why you were misled into thinking it was my video. The attribution to Takeshi K is not very clear, and even worse, the video had an overlay (Now Removed) which said "Nifty Access" - Definitely misleading you to believe it was my video. This was completely unintentional. I use a template process and the template has the overlay already built in. I mostly post my own videos on my website. However since you've brought this to my attention, I will make sure there are no other cases of me misleading people! So thank you for bringing this this to light, as it could have caused major embarrassment!
 
Local time
Today, 14:14
Joined
Feb 2, 2020
Messages
45
Thanks! Check this out and let us know if you have any questions.
Thank you very much for your help. While the solution is seemingly simple for you, my skill set is not there "yet". Every little bit helps.
I will mark the post as solved.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom