Full Version: Multi Value Combo
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
ScorpDevil
Hi There,

I’m having a hard time figuring this out:

How can you loop thru selected ItemData in a multi value combo box?

CODE
        If Me.cmbEmail.ItemsSelected.Count > 0 Then
            For Each varSelected In cmbEmail.ItemsSelected
                strTo = strTo & "; " & Me.cmbEmail.ItemData(varSelected)
            Next varSelected
        End If


I’ve tried the above but nothing.

Any idea how to get the selected rows?
Larry Larsen
Hi
I know very little but have seen some details about these MVF..

Check out: MVF Controls in A2007.
thumbup.gif
Peter46
There is no such thing as a multi-select combo box (at least, not one you can create).

Are you referring to a listbox?
ScorpDevil
Larry - Thanks a lot.

Peter - I don't know what to say. It's a new feature that started with Access 2007. It's basicaly a bound combo to a multi-value field.

Thank Guys thumbup.gif
GroverParkGeorge
Yes, you mean a Multi-Value Field, and it is implemented on a form in a way that APPEARS similar to the standard combo box. It is not a combo box, and you can't work with it the same way.

Bernie's Demo is excellent. But note how complex the code is! If you REALLY, REALLY want to use the MVF, be prepared to deal with that deeper level of complexity.
BruceM
I do not have Access 2007 here, and where I do have it I have not worked with multi-valued fields. As pointed out in the linked article, the data actually are stored in a hidden table, so nomalization rules are not necessarily broken, but the functionality is hidden from view. I would prefer to have it in the open where I can keep an eye on it smile.gif

In any case, the article mentioned:
QUOTE
The coding required for MVFs is not dissimilar to coding required for standard fields; the main difference is in adding the term ‘.value’ to the MVF field when referencing them

Have you implemented that? It is not apparent from your code snippet.

The article also offers the caveat that MVFs are not compatible with other database systems (including earlier versions of Access). Even if the tables are converted to visible tables, queries will need to be rewritten. You may want to consider carefully whether you are comfortable with that limitation.
ScorpDevil
Hi GroverParkGeorge,

I did some research about it and that's how Microsoft Calls it a Multi Value Combo Box, sorry if I was referring to something different.

But anyways, thanks to you all I learned the important part that you can’t loop like a normal combo box control when searching for “checked” values, you have to go to the table and obtain the values from there.

Thanks a lot…
You guys are the best.
GroverParkGeorge
I know, MS likes to obscure things for the sake of "user-friendliness". I have to acknowledge it is a combo box in a sense, but because it's bound to an MVF, it's not the same thing as the native Access combo box.



hk1
Here's how I access the selected values in a multi-value combo:

CODE
        If IsNull(Me.cboSearchState.Value) = False Then
            Dim a()
            a = Me.cboSearchState.Value
            
            Dim i As Integer
            For i = 0 To UBound(a)
                Debug.Print a(i)
            Next i
        End If


In my opinion, you should never use them for anything other than a filtering control. This way the stored data is completely inconsequential to your application. You do have to bind the control to a multi-value field but this is as simple as creating a local table for your filtering form. Usually my filtering forms are unbound (the subform is bound) but in this case I basically have a table (tblContactsFilter) that has one record, and probably only one or two fields. I just posted an example a few days ago: http://www.UtterAccess.com/forum/Multi-Com...l-t1987196.html
fkegley
I have been successful going through the values in a multi-value field using the Like operator in queries:

Like "*" & [FieldNameGoesHere] & "*"

You do need to be careful that there is no ambiguity in the characters that make up the MVF.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.