Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing two fields in a combo box once selected

Status
Not open for further replies.

dkwong

MIS
Dec 27, 2001
76
CA
I have a combo box that displays all the employees in the Employee table. In the drop down, both Last Name and First Name are displayed, but once selected, only the Last Name is visible. In the combo box wizard, I select EmployeeID, EmployeeLastName, and EmployeeFirstName and specify the key column, EmployeeID to be hidden. Any idea how to get both Last and First Name to remain displayed in the combo box once selected? Thanks!
 
This is strange. Are you doing anything in the code that might cause this? Is there an OnClick event attached to the combo box? Do you lose the first name no matter which row is selected? What do you see in the column where the first name used to be? Just white space? dz
 
Here's some more information for the combo box:

Row Source:
SELECT DISTINCTROW [Employee].[EmployeeID], [Employee].[EmployeeLastName], [Employee].[EmployeeFirstName] FROM [Employee] ORDER BY [Employee].[EmployeeLastName], [Employee].[EmployeeFirstName];

Bound Column:
1

The EmployeeID is getting passed. When you scroll through the combo box, the Last and First name are visible, but once selected, only the last name is displayed (nothing for the first name, just white space) no matter which row is selected. There is no event attached to the combo box. As far as I know, there's nothing in the code that would cause this.
 
Hi,

I don't mean to doubt you, but did you check to make sure that there aren't any events attached to the combo box? That is the only thing that I can think of that would cause this behavior. I'd like to look at your database if you want to email it to me. If you want me to look at it, please post your email address and I'll reply to you. This one has me curious! :eek:) dz
 
Hi there!

The combo control only displays the first visible field after selection. One way to get both names showing is to concatenate them into one field inside your SQL statement in the row source.

 
My bad. I was confusing a list box with a combo box. A combo box can only display a single column once selected. If you want to use a combo box, you can do like Jaggernull suggested; however, you won't be able to use a multi-column combo box. The name would be concatenated in a single column. If you want to keep the first name and last name in separate columns, you could use a list box instead. Thanks for correcting my error, Jaggernull. dz
 
Concatenating seems to work, but when I click the combo box, I see one column with [Last Name], [First Name] (as I defined) and the other column that is blank/white. How can I get rid of the blank column. The combo control only displays the [Last Name], [First Name] once selected.

Here's my row source now:

SELECT DISTINCTROW Employee.EmployeeID, Employee.EmployeeLastName & ", " & Employee.EmployeeFirstName AS EmployeeName FROM Employee ORDER BY Employee.EmployeeLastName & ", " & Employee.EmployeeFirstName;

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top