Combo Box Additem

I have 5 combo boxes on a form.  these boxes are filled with the function shown below.  What I can't seem to figure out is how to "additem" for something not already on the list generated by the function.  Anyone got an idea?

Public Function RDcomboPaint() As ADODB.Recordset
Dim ssql As String
Dim rsc As ADODB.Recordset
Dim msgr As VbMsgBoxResult
    ssql = "SELECT itemnmbr "
    ssql = ssql & "FROM itemlist "
    Set rsc = New ADODB.Recordset
        With rsc
            .Open ssql, CN, adOpenDynamic
            Do Until rsc.EOF
                cboPt1.AddItem rsc![itemnmbr]
                cboPt2.AddItem rsc![itemnmbr]
                cboPt3.AddItem rsc![itemnmbr]
                cboPt4.AddItem rsc![itemnmbr]
                cboPt5.AddItem rsc![itemnmbr]
        End With
End Function
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
I'm not entirely sure I understand what you mean, but you can just pass a string to the AddItem method:

    cboPt1.AddItem "wibble"
    cboPt2.AddItem "wibble"
    cboPt3.AddItem "wibble"

 etc, etc
PioneermfgAuthor Commented:
My quetion is how can my users add an item not already in the list?
Carl TawnSystems and Integration DeveloperCommented:
If its an editable combo then you can use the lostfocus event, check the Text property and compare it to the entries in the list and add it if its not already there.

Alternatively, give them a text field where they can type some text, and then add it to the list via the AddItem method.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Why don't you use DISTINCT in your SQL statement ?

ssql = "SELECT DISTINCT itemnmbr FROM itemlist "
You might also order your recordset:

ssql = "SELECT DISTINCT itemnmbr FROM itemlist ORDER BY itemnmbr"
PioneermfgAuthor Commented:
first off the itemlist is already sorted.  How do I tell if the combobox is editable?
Carl TawnSystems and Integration DeveloperCommented:
Its Style property will be set to "Dropdown Combo"
PioneermfgAuthor Commented:
It is set to dropdown combo.
Carl TawnSystems and Integration DeveloperCommented:
Then the user should be allowed to enter their own value, or choose from the list. So, if you want what the user enters to be added to the list you need to handle the LostFocus event, check if the item is in the list, and add it id it's not (maybe prompting the user to confirm first)
PioneermfgAuthor Commented:
ok, how?
Carl TawnSystems and Integration DeveloperCommented:
Private Sub Combo1_LostFocus()

    Dim sNewVal As String
    If ListIndex = 0 Then
        sNewVal = Combo1.Text
        For i = 1 To Combo1.ListCount
            If Combo1.List(i) = sNewVal Then Exit Sub
        Next i
        '// If we get here the new value isn't in the list
        Combo1.AddItem sNewVal
        Combo1.Text = ""
    End If

End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PioneermfgAuthor Commented:
Thank you!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.