Search list box

chestera
chestera used Ask the Experts™
on
Hi EE
I have the following
Dim i As Long
Dim Intnum
Intnum = Me!txtOrg
With Me!lstCompany
    For i = 0 To .ListCount - 1
        If .Column(2, i) Like Intnum Then
            .Selected(i) = True
            Exit For
        End If
    Next i
End With
Me!lstCompany.SetFocus

example. I have a list box of client details I need to search for names beginning with first two or three characters of a name. I have a name called Donards and would like to enter Don for a search. With the above code I have to enter the full name Donards for it to work.
Any help appreciated

chestera
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Team Lead
Commented:
try this...

Dim i As Long
Dim Intnum
Intnum = Me!txtOrg
With Me!lstCompany
    For i = 0 To .ListCount - 1
        If instr(1, .Column(2, i), Intnum) > 0 Then
            .Selected(i) = True
            Exit For
        End If
    Next i
End With
Me!lstCompany.SetFocus

Author

Commented:
Ryan Chong

Thank you Ryan works like a charm

lan

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial