concatenating fields in a combo box.

G

Guest

Hi,

I am filling in a combobox. I would like to concatenate two fields into the
data combo box and display "last name, first name"

I tried to displaymember = "employee_last_name" & ", " &
"employee_last_name", but it did not like that.

I can fill the combo box with either the first or the last, but I cannot
manage to concatenate it.

Any suggestions? My code is below.

'fill employee combo box.
strsql = "SELECT * FROM Employee order by employee_last_name"
' Create data adapter object
Dim daEmployee As OleDbDataAdapter = New OleDbDataAdapter(strsql,
TSA.conn)
' Create a dataset object and fill with data using data adapter's
Fill method
Dim dsEmployee As DataSet = New DataSet
daEmployee.Fill(dsEmployee, "Employee")
' Attach dataset's DefaultView to the datagrid control
Dim dvEmployee As DataView = dsEmployee.Tables("Employee").DefaultView
ComboBox5.DataSource = dvEmployee
ComboBox5.DisplayMember = "employee_first_name"

Thanks in Advance!!
Elena
 
T

tomb

Try concatenating the names in the query with an assigned column name,
and list the specific columns you want instead of using *, which pulls
every column.

Tom
 
G

Guest

How would I then change the .displaymember? It does not read the data view,
nor can I pull concatenated fields.

Thanks,
Elena
 
J

James

He meant do something like this:

Select Employee_Last_Name + ', ' + Employee_First_Name AS Employee_Full_Name
FROM Employees ORDER BY Employee_Last_Name

....and then use Employee_Full_Name as your display member.
 
G

Guest

PERFECT!! thank you :)

James said:
He meant do something like this:

Select Employee_Last_Name + ', ' + Employee_First_Name AS Employee_Full_Name
FROM Employees ORDER BY Employee_Last_Name

....and then use Employee_Full_Name as your display member.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top