Ok, this explanation is definately different than what I first understood.
First, using last name and first name combined as a primary key can cause a
problem, what if you have two John Smiths? From the way you worded the
question compared to how you listed the tables, I'm not sure which way you
went, but I believe you are actually using the ID field as the primary key.
Now, to help the users use the combo boxes. For the first combo box (last
name) set its Row Source to a query that will return just ONE of each last
name.
Example:
SELECT DISTINCT Demo.LastName
FROM Demo
ORDER BY Demo.LastName;
For the second combo box, set its Row Source to a query that relies on the
value in the first combo box.
Example:
SELECT Demo.ID, Demo.FirstName, Demo.SSN
FROM Demo
WHERE Demo.LastName = """" & Forms!frmMyForm!cboFirstCombobox & """"
ORDER BY Demo.FirstName
In the second combo box's Properties sheet, set the number of columns to 3,
the column widths to 0", 1", 1" (adjust the last two as desired to show the
data without cutting it off), and set the Bound Column to 1. The Limit to
List option will automatically be set to Yes. For the SSN textbox, set its
control source to =cboCombo2.Column(2). The Column value is 0 based, so 2 is
the 3rd column.
You will need the SSN showing when you drop down the list to make the
selection becuase you will need to be able to distinguish between two people
with the same name.
--
Wayne Morgan
MS Access MVP
Praveen Manne said:
Hi Morgan,
Thanks for your prompt reply. I'm not that good in access, So I'm
getting
a
bit confused in it.
I will explain you the full scenario here, so that you may be able to solve
my problem ...
I have 2 tables;
1. Demo: ID, LastName, FirstName (fields in the table Demo) ID is the
Primary key.
2. Orders: Last Name, First Name, NoOfOrders .......
I chose Last Name and First Name as the primary fields because I want the
users of this application, be able to select the Names from a combo box
instead of selecting their ID's.
Here I have 2 problems,
1. when I select Last Name in the first combo, it should filter the values
in the First Name combo. ( I tried so many ways to do this, but I failed all
the times)
2. And when the First Name Combo got selected, I want the SSN textbox field
which is empty, should populate the correct SSN value from the first table.
Please Help
Thanks
Praveen Manne
You could use the DLookup function in a calculated control.
Example control source for textbox:
=DLookup("[FieldName]", "[Table 1]", "[IDField]=" & txtIDField) +
DLookup("[FieldName]", "[Table 2]", "[IDField]=" & txtIDField)
FieldName would be the name of the field in each table. IDField would
be
the
name of a field in each table that matches a unique value in the current
record. txtIDField is a textbox on the form that holds this unique value.
--
Wayne Morgan
MS Access MVP
HI,
How to manipulate records of 2 different tables on a form. Can
anyone
help
me in the correct syntax?
for eg: 23 is in table 1
and 75 is in table 2
how to add these two numbers on a form which is bounded to another table?
Thanks
Praveen