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 4 11748
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
Elena wrote: 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
How would I then change the .displaymember? It does not read the data view,
nor can I pull concatenated fields.
Thanks,
Elena
"tomb" wrote: 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
Elena wrote:
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
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.
"Elena" <El***@discussions.microsoft.com> wrote in message
news:AD**********************************@microsof t.com... How would I then change the .displaymember? It does not read the data view, nor can I pull concatenated fields.
Thanks, Elena "tomb" wrote:
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
Elena wrote:
>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 > >
PERFECT!! thank you :)
"James" wrote: 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.
"Elena" <El***@discussions.microsoft.com> wrote in message news:AD**********************************@microsof t.com... How would I then change the .displaymember? It does not read the data view, nor can I pull concatenated fields.
Thanks, Elena "tomb" wrote:
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
Elena wrote:
>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 > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Craig |
last post by:
I am connecting to an Access DB using ODBC.
In my SQL statement I have Field1 + ' ' + Field2 and a field is NULL it
returns NULL
1 field may contain NULLs
So NULL + "Text" = NULL
How can...
|
by: john |
last post by:
In a query I have the fields Letter, Prefix, and Surname. I need to make a
report in which there is one field called Name which is a concatenation of
the three fields.
When I do this:
Expr2: +"...
|
by: exapplerep |
last post by:
I've seen how to use VBA code to concatenate two fields into a third by
using an expression in the "After Update" property in fields 1 & 2.
field3 = field1 + field2
The above code would go...
|
by: JRNewKid |
last post by:
I want to concatenate two fields on a report. They are two text fields,
wrkDescription is 10 characters long and wrkTextDescription is 255.
I have them concatenated in the report but I'm only...
|
by: zuchowra |
last post by:
Hi everyone. I need help. I have a combo box in my form that i want to populate multiple text boxes after you select your selection in the combo box. Here is my set up.
The Fields that need to be...
|
by: banderson |
last post by:
Hello,
I have a combo box in which I want to display multiple fields by concatenating the fields together. If one of those concatenated fields is Null, then the combo box does not show anything. To...
|
by: Whizzo |
last post by:
Hi all;
I'm using this great bit of code to concatenate a fields from multiple rows into a single one.
'Concat Returns lists of items which are within a grouped field
Public Function...
|
by: banderson |
last post by:
Hello all,
I have a table "tblContacts" that holds my Contact Info. Because there can be multiple Contact Types for a Contact, I have a second table "tlnkContactTypes" in which there is a record for...
|
by: Gordon Padwick |
last post by:
A form contains controls, one or more of which can be other forms. A form that contains another form is known as a main form. A form contained by a main form is known as a subform. A subform itself...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |