Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to allow for mulitple selections from a Combo Box Control

Status
Not open for further replies.

dragongunner0351

Programmer
Mar 16, 2006
104
US
Hello all,
I was wondering the best way to allow the user to make multiple selections from a combo box control.

I'm thinking that I will need to have an unbound control that allows for the mulitiple selections to be stored in.

Also, I would like to seperate each selection with a comma or semi-colon. In the future I will make a query to sort my customers by what the users had selected.

Am I on the right path? if so or if not, anyone with experience in this situtation please let me know.

best regards and
Good Veterans Day to all Vets

Semper Fi!
 
Where your unbound textbox is named HoldingBox:

Code:
Private Sub YourComboBox_AfterUpdate()
 If IsNull(Me.HoldingBox) Then
   Me.HoldingBox = Me.YourComboBox
 Else
   Me.HoldingBox = Me.HoldingBox & "; " & Me.YourComboBox
  End If
 End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
OF course, I was assuming that you knew that a listbox offered a multi-select option, but wanted features of the combobox that a listbox doesn't have!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks for the reply, I would have liked to use the listbox but as you stated I need the features of a combo box. Thanks for the assistance.

 
I tried your suggestion and it works, however, how do I get the holdingbox to show the Code Name and not the ID number.

The structure is like this:
On the form the Combo Box Control is labeled "CustCode"

The combo box control source is a table with Three fields
1. ID (autonumber, primary)
2. CODE (name of customer code)
3. DESCRIPTION (desc. of customer code)

Thanks again for the help
 
Have a look at the Column property of the ComboBox object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

As PHV suggested, in the code replace

Me.YourComboBox

with

Me.YourComboBox.Column(0).Value
Me.YourComboBox.Column(1).Value
Me.YourComboBox.Column(2).Value

depending on which column Code is. I'm guessing it would be

Me.YourComboBox.Column(1).Value

which is the 2nd column, the Column indexes being zero- based.



The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I put the following code in after update:

Private Sub CustCode_AfterUpdate()
If IsNull(Me.CustCodeList) Then
Me.CustCodeList = Me.CustCode.Column(1).Value
Else
Me.CustCodeList = Me.CustCodeList & "; " & Me.CustCode.Column(1).Value
End If

End Sub

I am getting and Errore 424, object required. Any suggestions. I've tried changing the column value but no luck.

Thanks in advance.
 
I believe I got it to work properly, but if you could help me understand I would appreciate it.

I replaced Me.CustCode.Column(1).Value with Me.CustCode.Column(1) and it works properly, like I said I don't know exactly why, but if you have further insight I appreciate it.

Thanks MissingLinq
 
I'm sorry, that was a typo! The value shouldn't have been there! Glad you got it working anyway!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Now PHV, what fun is that?

;0)>

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
How are ya dragongunner0351 . . .

My first shot is scanty due to a lack of info, but here goes. Using a listbox:
Code:
[blue]Public Function Fltr() As String
   Dim Lbx As ListBox, Pack As String, itm
   
   Set Lbx = Me!ListboxName
   
   For Each itm In Lbx.ItemsSelected
      If Pack <> "" Then
         Pack = Pack & "," & Lbx.Column(1, itm)
      Else
         Pack = Lbx.Column(1, itm)
      End If
   Next
   
   Fltr = Pack
   Set Lbx = Nothing
End Function[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 

Thanks for the reply, I would have liked to use the listbox but as you stated I need the features of a combo box

You got to pay attention, AceMan!

You notice that I omitted the 1! Seems like overkill, as we all know that you are Number One!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
missinglinq . . .

Realization hit me after submitt! . . . What could I do! ;-)

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 

That's what they all day! LOL!

Seriousness aside, that's my second biggest gripe with this site, not being able to edit your post when you realize you've stepped in something other than clover! My biggest gripe is having to manually enter tags to make text stand out! I know, I know, it's FREE! But so are other sites that have these features, and they don't have those annoying popup ads that appear if you trip across the underlined words; my third gripe! And this really is one of my favorite sites!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
missinglinq . . .

Not only that but the latest Adobe Flash has bugs in it and can cause your browser to hang! Its has the nasty habit of happening to me when I'm in the middle of a post and go back thru the thread to verify info. I'll hit one of those guys . . . Arrrrrrrrrrrrgggghhhhhhhhhhh!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
If only the world were as perfect as you and I, AceMan!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top