combo box help - newbie

  • Thread starter Thread starter p-rat
  • Start date Start date
P

p-rat

I have a combo box that brings a list of Names from a query. When
clicking on the down arrow it shows a list containing two columns;
Last Name and First Name. When you chose a name from the list though
it only pulls in or leaves in the box the Last Name. Does anyone know
what stupid thing I'm doing wrong? Thanks in advance for your help.
 
You have two columns in your combo. Only one column can be bound. It is the
only column that is returned if you use = Me.MyCombo.
If you want them both, you can use SELECT FirstName & " " & LastName AS
WholeName From myTable:

Then you will have only one column and you will see both names.
 
This is normal behaviour for a combo box.
What do you want to happen after you choose LastName from the combo?
Usually the combo has a hidden column with the ID from the table with
LastName and FirstName.
That 1st column is usually hidden, after you choose LastName from the combo,
the ID is used to either save in a control on your form or to find a
matching record in your form.

Jeanette Cunningham
 
I have a combo box that brings a list of Names from a query. When
clicking on the down arrow it shows a list containing two columns;
Last Name and First Name. When you chose a name from the list though
it only pulls in or leaves in the box the Last Name. Does anyone know
what stupid thing I'm doing wrong? Thanks in advance for your help.

You haven't done anything wrong, per se - just not done what you want!

A dropped-down combo box will display all of the nonzero width columns in its
RowSource property, up to the ColumnCount property. When it's not dropped down
it will display only the first nonzero width column.

If you want to see the full name, use a calculated field in the query such as:

SELECT PersonID, [LastName] & ", " & [FirstName], <other fields as needed>
FROM tablename
ORDER BY LastName, FirstName;

Hints:

- Don't store names in any other table, they're not unique and people do
change their names. Store a unique ID instead.
- Don't use blanks in fieldnames; you *can* but it can lead to hassles later.
I use "camel case" - e.g. FirstName.

John W. Vinson [MVP]
 
Back
Top