How do I set up a value based on another box's value in access?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
Is there a reason you can't have one combo box with 4 columns instead of 4
separate combo boxes ?
 
I need to show all 4 items in a report, can it be done in one combo box. I
only know how to show one of the values in a combo box?
When I set up the table I set up different fields for sorting reasons.
Thank you!
 
Yes you can, whatever is selected in the combo box you can get at the other
columns like this

=ComboBox.Column(1)
=ComboBox.Column(2)
etc.
 
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
 
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.
 
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
 
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!

Sprinks said:
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

idontgetit said:
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.
 
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

idontgetit said:
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!

Sprinks said:
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

idontgetit said:
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!
 
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!

Sprinks said:
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

idontgetit said:
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!

Sprinks said:
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!
 
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!

Sprinks said:
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

idontgetit said:
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!
 
Yes, i made up a different table for the expenses and I think solution 1
would work best for me, I do not have a primary key on any of the names so I
don't think I can do #2.
I am a little confused on the formula though.
My combo box is labelled first name (the combo box shows first name and last
name). When I make a text box and go to the control source what do I type:
=firstname.columnlastname ?????



Sprinks said:
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!

Sprinks said:
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!
 
Aha! I suspected as much! :)

Firstly, I'll answer your question directly, but please read on.

If your combo box' Name property is FirstName, and the columns in the
RowSource are the first and last names, respectively, the ControlSource of
the textbox would be:

=FirstName.Column(1)

1 refers to the 2nd column of the combo box, since the indexing begins with
zero.

However, I strongly advise you to add an AutoNumber primary key to your
Employee table. In a relational database, *every* table should have a
primary key that uniquely and unambiguously identifies a given record. Life
gets very easy when you do. Then your name field in the Expenses table would
be a *numeric* field (of type Integer) that corresponds to the AutoNumber
primary key in Employees. It is called a foreign key in Expenses.

Then you set the ControlSource of the combo box to this numeric field, but
set the columnwidth of the column to 0", so that the 2nd column displays
instead of the first when the user makes a suggestion.

I also suggest you read up on the topic "Database Normalization" which
should clear up a lot of application design issues. I personally think that
it's the most important topic in database design, because having
well-normalized tables makes forms, queries, reports, and coding much, much
easier.

Sprinks


idontgetit said:
Yes, i made up a different table for the expenses and I think solution 1
would work best for me, I do not have a primary key on any of the names so I
don't think I can do #2.
I am a little confused on the formula though.
My combo box is labelled first name (the combo box shows first name and last
name). When I make a text box and go to the control source what do I type:
=firstname.columnlastname ?????



Sprinks said:
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!
 
Thank you very much for ALL YOUR HELP!!!!

Sprinks said:
Aha! I suspected as much! :)

Firstly, I'll answer your question directly, but please read on.

If your combo box' Name property is FirstName, and the columns in the
RowSource are the first and last names, respectively, the ControlSource of
the textbox would be:

=FirstName.Column(1)

1 refers to the 2nd column of the combo box, since the indexing begins with
zero.

However, I strongly advise you to add an AutoNumber primary key to your
Employee table. In a relational database, *every* table should have a
primary key that uniquely and unambiguously identifies a given record. Life
gets very easy when you do. Then your name field in the Expenses table would
be a *numeric* field (of type Integer) that corresponds to the AutoNumber
primary key in Employees. It is called a foreign key in Expenses.

Then you set the ControlSource of the combo box to this numeric field, but
set the columnwidth of the column to 0", so that the 2nd column displays
instead of the first when the user makes a suggestion.

I also suggest you read up on the topic "Database Normalization" which
should clear up a lot of application design issues. I personally think that
it's the most important topic in database design, because having
well-normalized tables makes forms, queries, reports, and coding much, much
easier.

Sprinks


idontgetit said:
Yes, i made up a different table for the expenses and I think solution 1
would work best for me, I do not have a primary key on any of the names so I
don't think I can do #2.
I am a little confused on the formula though.
My combo box is labelled first name (the combo box shows first name and last
name). When I make a text box and go to the control source what do I type:
=firstname.columnlastname ?????



Sprinks said:
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

:

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!
 
Sprinks- it's your nightmare back!
Do you know why the values that drop into those boxes aren't stored in my
table ???
Thank you!

Sprinks said:
Aha! I suspected as much! :)

Firstly, I'll answer your question directly, but please read on.

If your combo box' Name property is FirstName, and the columns in the
RowSource are the first and last names, respectively, the ControlSource of
the textbox would be:

=FirstName.Column(1)

1 refers to the 2nd column of the combo box, since the indexing begins with
zero.

However, I strongly advise you to add an AutoNumber primary key to your
Employee table. In a relational database, *every* table should have a
primary key that uniquely and unambiguously identifies a given record. Life
gets very easy when you do. Then your name field in the Expenses table would
be a *numeric* field (of type Integer) that corresponds to the AutoNumber
primary key in Employees. It is called a foreign key in Expenses.

Then you set the ControlSource of the combo box to this numeric field, but
set the columnwidth of the column to 0", so that the 2nd column displays
instead of the first when the user makes a suggestion.

I also suggest you read up on the topic "Database Normalization" which
should clear up a lot of application design issues. I personally think that
it's the most important topic in database design, because having
well-normalized tables makes forms, queries, reports, and coding much, much
easier.

Sprinks


idontgetit said:
Yes, i made up a different table for the expenses and I think solution 1
would work best for me, I do not have a primary key on any of the names so I
don't think I can do #2.
I am a little confused on the formula though.
My combo box is labelled first name (the combo box shows first name and last
name). When I make a text box and go to the control source what do I type:
=firstname.columnlastname ?????



Sprinks said:
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

:

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!
 
Back
Top