Different Autocomplete CustomSource for the same Textbox

I have one Textbox  as a search Control . Is it possible to have 2 different autocomplete custom sources for the same control?
The one source includes only numbers and the other only letters
I have in mind  Key press event to separate digit from letters but is this a good choise....
'Autocomplete code
Private Sub AutocompleteSearch1()
        Dim AutoLastnameconn As New SqlConnection(ProjectConnectionString)
        Dim AutoLastnameda As SqlDataAdapter = New SqlDataAdapter("SELECT Key_Personnel,ASMA FROM Personnel ORDER BY ASMA", AutoLastnameconn)
        Dim AutoLastnameds As DataSet = New DataSet
        Dim acLastname As New AutoCompleteStringCollection
        AutoLastnameda.Fill(AutoLastnameds, "Personnel")
        For Each AutoLAstnamedr As DataRow In AutoLastnameds.Tables("Personnel").Rows
            acLastname.Add(AutoLAstnamedr.Item("Lastname").ToString)
        Next
        TextBox1.AutoCompleteCustomSource = acLastname
        TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
    End Sub

Open in new window

LVL 18
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAsked:
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.

Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,
the best for you can be to use union in sql or merge data in single table
for union you can use following code

 
Private Sub AutocompleteSearch1()  
        Dim AutoLastnameconn As New SqlConnection(ProjectConnectionString)  
        Dim AutoLastnameda As SqlDataAdapter = New SqlDataAdapter("SELECT Key_Personnel,ASMA FROM Personnel union SELECT col1,col2 FROM tbl2 ORDER BY 2", AutoLastnameconn)  
        Dim AutoLastnameds As DataSet = New DataSet  
        Dim acLastname As New AutoCompleteStringCollection  
        AutoLastnameda.Fill(AutoLastnameds, "Personnel")  
        For Each AutoLAstnamedr As DataRow In AutoLastnameds.Tables("Personnel").Rows  
            acLastname.Add(AutoLAstnamedr.Item("Lastname").ToString)  
        Next  
        TextBox1.AutoCompleteCustomSource = acLastname  
        TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend  
    End Sub

Open in new window


for the other way populate othe table too and copy the rows from second table to first and use the first
0

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
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
Yes i understand that...There might be an event on how chose between the one source and the other...
ifthe user press a number then the autocomplete must change to populate the codes for example..if there is a letter then the other source must populate..
i have 2 diiferent subs like the one above.
Thank you
0
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
mmmm thinking now clearly...there is a logic on your suggestion...let me try it...
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
It will automatically filter the data and will show which is closer.
0
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
as you have numeric data and other is alphabetic/letters so you will never be mixed.
0
John (Yiannis) ToutountzoglouInstructor Multiengine PilotAuthor Commented:
yeap .....union...is a good choise....thanks..
0
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.NET

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.