Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loading datatable rows into a textbox

Posted on 2012-04-02
4
Medium Priority
?
476 Views
Last Modified: 2012-04-03
Hi Experts,

I am currently using a textbox as a search field and am using autocomplete as follows...

 Dim r As DataRow

            C1TextBox1.AutoCompleteCustomSource.Clear()

            For Each r In dt1.Rows

                C1TextBox1.AutoCompleteCustomSource.Add(r.Item(0).ToString)

            Next

This returns the name of the company, which is all well and good. But i'd also like to have the company reference next to the company name in brackets, is this possible? I am currently pulling back the company reference in the second column of the data table.

So I would like...

COMPANYNAME (COMPANYREF)


Many Thanks,
Dean
0
Comment
Question by:deanlee17
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
Imran Javed Zia earned 2000 total points
ID: 37797004
Hi,
You can use it as foolowing:

C1TextBox1.AutoCompleteCustomSource.Add(r.Item(0).ToString + " (" + r.Item(1).ToString + ")")


Thanks
0
 

Author Comment

by:deanlee17
ID: 37799646
Ok we are almost there, see attached print screen, the closing bracket almost has a tab before it on some drop down items?

Code is currently...

C1TextBox1.AutoCompleteCustomSource.Add(r.Item(1).ToString + " (" + r.Item(0) + ")")
problem.png
0
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 37799651
Just trim the data so use as following:

r.Item(1).ToString().Trim()
0
 

Author Comment

by:deanlee17
ID: 37799660
Ah of course.

Thanks alot.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question