Search *parts* of string in combo box

mz-ler

Registered User.
Local time
Today, 11:13
Joined
Feb 21, 2005
Messages
16
Hi,
there is probably an answer to this in the forum - but I don't seem able to find it.

I have a form with data on meetings. I also have a table with titles of protocols (10-30 words) and hyperlinks that need to be asssociated with these meetings.

What I would like to do is have a combo box where I can type in ANY word from the protocol title and get a selection of matching documents to chose from.

Thanks a lot for your help!
B.
 
Hello

this can be achieved by using a LIKE statement on the afterupdate event of the combo box you want the user to type in the word they are looking for, this will then check the protocols combo box, once a protocol contains the word you are looking for we can add this in a temporary variable and when complete pass the overall result back to say a text box.

I have attached an example of how this could be done.

Hope this helps.
 

Attachments

Update same combo box with search results

Thanks a million, vodafrog! :)

It works well. Now, my ideal solution would be if the combo updated itself with with the results of the search. My idea was to split up the results of the search, write them into an array and then use the array to re-populate the combo. However, with my modifications i keep getting incomaptible types errors for the marked (###) line. However, this should work, shouldn't it?

Help is very much appreciated.

THANKS,
B.

Code:
Private Sub Combo2_Change()
Dim tmpstring As String
Dim combostring As Variant
Dim tmpcheckstring As String


x = 0
y = 0
tmpstring = ""
combostring = ""
tmpcheckstring = "*" & Me.Combo2.Text & "*"



Do Until x > Me.Combo2.ListCount
    If Me.Combo2.ItemData(x) Like tmpcheckstring Then
        tmpstring = tmpstring & Me.Combo2.ItemData(x) & ";"
    End If
    x = x + 1
Loop


y = x
x = 0

combostring = Split(tmpstring, Chr(32))


Do Until x = y
    Me.Combo2.ItemData(x) = combostring(x) '###
    x = x + 1
Loop

End Sub
 
You should clear the combobox first before you attempt to replace it with the data you have found.

Me.Combo2.RowSource = ""

In order to add data to a combobox you need to use the Additem statement: -

Do Until x = y
Me.Combo2.AddItem (combostring(x))
x = x + 1
Loop
 

Users who are viewing this thread

Back
Top Bottom