OK. You didn't say specifically, but I will assume that you have a second
table called something like Expenses.
A combo box, when gets its rows from an existing table or query, limits
selection to previously entered records. Once a row is selected, the *value*
of the combo box is the value in the Bound Column of the row. What is
*displayed* in the box after selection is the first column with a non-zero
width as defined in the ColumnWidths property. Usually, you would set the
BoundColumn to the primary key, and set its ColumnWidth to 0", so you get
more meaningful information displayed.
With a name as you've discovered, you really wish to display two bits of
information once the user has selected the Row. You have two options:
1) include the other name field in the RowSource statement, and add a
textbox to display it by setting its ControlSource to
=YourComboBox.Column(x), or
2) change your RowSource statement to display a calculated field made up of
both names:
SELECT EmployeeID, LName & ", " & FName From YourTable
In both cases, the BoundColumn should be the one with the primary key, and
the ControlSource of the combo box should be the numerical foreign key field
in Expenses corresponding to the foreign key.
I hope that helps.
Sprinks
idontgetit said:
I have one table (Tbl_Names and Info) with fname, lname, bday, start date,
etc. that holds all the personal records. I can pull all kinds of reports
from this- b-day for the month, etc.
What I'm trying to do is : pull Bob Smith from (Tbl_Names and Info) and
enter any expenses that we owe them. When I do a combo box I can show the
first and last name (Bob Smith) but b/c these are two different fields, I can
either get the first or last name in as the value. I have to set up another
combo box for Bob and select the another combo box for Smith. Can I set this
up so that when I select Bob- Smith drops into it's own value?
I hope I'm explaining this enough? If not, let me know.
Thank you very much for your time!
:
I'm not sure what you're trying to do.
Please post your combo box' RowSource property, and the name of the form's
RecordSource property.
Sprinks
:
I'm sorry if I'm hard to understand, thank you for your patience and this is
the last question.
It's a combo box- I understand the bound column, but can i make it show more
than one column? When I bound to the first name (column 2) only the first
name comes up, not Smith AND BOB. ????
Thank you!
:
Is the name a combo box or a textbox? If it is a textbox, change the
ControlSource to [LName] & ", " & [FName] to display the full name, or add
another textbox for the other field.
If it is a combo box, change the RowSource as I suggested in my earlier post.
Sprinks
:
Thank you very much for your help!! One questions I have than is when I'm
entering both Bob Smith and Sam Smith in a form to enter b-day's- I only show
Smith and not sure which one b/c I don't have that other field showing.
:
In a relational database, you want to store "attributes" (fields) of "things"
(tables) ONCE. It sounds like you're trying to store the Birthday, LName,
FName, and YearsEmployed in some table other than the Employee table. For
example, an Employee table might have the fields:
EmployeeID AutoNumber (Primary Key)
FName Text
LName Text
Birthday Date/Time
YearsEmployed Integer
Phone Text
Extension Text
WorkGrade Text
Salary Currency
...etc.
If you wish to have an Employee field in ANY OTHER table, all you need to
store is the primary key EmployeeID field. All other fields can be obtained
for a report or for display on a form through a query, or by including them
as columns in a combo box, and using the Column property to display them in
other UNBOUND textboxes.
So what you need is a single combo box Bound to a numeric field, and
textboxes to display other columns that you include in the Row Source of the
combo box.
Combo Box Properties
---------------------------
RowSource SELECT EmployeeID, FName, LName, Birthday, YearsEmployed FROM
YourTable
ORDER BY LName, FName;
Bound Column: 1
Column Count: 5
ColumnWidths: 0";x",y";0",0", where x and y are large enough to display the
widest FName & LName, respectively
To display another column in any unbound textbox, set its ControlSource to:
=YourComboBox.Column(x), where x is the column number, starting from zero
(for example, the third column's index is 2).
Two other comments:
- YearsofService would be better implemented by calculating it from a
HireDate.
- You may wish to combine the FName and LName for display in the combo box.
The EmployeeID will still be stored. The RowSource would then be:
SELECT EmployeeID, LName & ", " & FName AS FullName, Birthday, YearsEmployed
FROM YourTable
ORDER BY FullName;
Hope that helps.
Sprinks
:
I have worked on this problem for over a year and still have not conquered
it. Any help would be very much appreciated.
I have a form that is set up from a table. There are 6 combo boxes. Of the
6 combo boxes 4 of them refer to the same thing. Example: I have one box
for Joe (first name), one box for Smith (last name) another box for his
birthday and the last box for his years employeed. I set up the combo box so
that I have to click on each one individually and each time (4 times) and
click on Joe, Smith, b-day and years employed.
Is there a way to set the other 3 boxes based of the value that I select for
Joe. I have included all the information in every combo box to make sure I'm
pulling the right Joe.
Any ideas?
Thank you VERY MUCH!