M
mac
Summary:
1. I want to define a column in anMS Access table to be lookups on other
tables.
2. The table that is the data source (e.g the "parent" table) has a
composite
primary key.
3. When the "child" table does the lookup, it should pass all the columns
necessary
to properly restrict the data returned to the litbso for he lookup.
4. How do I accomplish this in a lookup?
Please, no suggestions to avoid lookups, etc. This is for a very quick and
dirty
"spreadsheet replacement" for a one time data mapping exercise I do
not have the time to write an app for this. I need to avoid code and just
use what I have
defined in the table structures and foreign keys.
The following example is fabricated, but it shows the idea. I know that the
keys in the example aren't ideal,
but it makes it easy to read the example.
ParentTable (Key is composite of (State, CityName):
[State], [CityName], [Population]
AZ Phoenix 1,000,000
GA Phoenix 8,000
AZ Tucson 500,000
ChildTable (Key is SalesmanID. State and CityName are part of a composite
foreign key that referes to the ParentTable.
[SalesmanID], [State], [CityName], [DateAssigned]
1 AZ Phoenix 1/15/2006
1 AZ Tucson 3/01/2006
3 GA Phoenix 1/15/2006
I want ChildTable.CityName to be a lookup possible values from ParentTable,
but I want the values shown in the lookup
to be restricted based on the State entered in the column ChildTable.State.
For example,
if you were in either of the first two rows of ChildTable, and hit the drop
down, you should see
'Phoenix' and 'Tucson'. If you were in the third row, you should only see
'Phoenix', but it would
be the Phoenix with a population of just 8,000 people.
If I define the column ChildTable.CityName as a lookup, I always see the
values Phoenix, Phoenix, Tucson, regardless
of which row I am on in Childtable.
How do I define the lookup so that the value from ChildTable is part of the
WHERE clause in the query that gets data
from ParentTable to populate the listbox? In other words, I want the query
to say WHERE State = 'AZ' when someone
invokes the lookup from one of the first two rows in ChildTable.
Thanks,
Mac
1. I want to define a column in anMS Access table to be lookups on other
tables.
2. The table that is the data source (e.g the "parent" table) has a
composite
primary key.
3. When the "child" table does the lookup, it should pass all the columns
necessary
to properly restrict the data returned to the litbso for he lookup.
4. How do I accomplish this in a lookup?
Please, no suggestions to avoid lookups, etc. This is for a very quick and
dirty
"spreadsheet replacement" for a one time data mapping exercise I do
not have the time to write an app for this. I need to avoid code and just
use what I have
defined in the table structures and foreign keys.
The following example is fabricated, but it shows the idea. I know that the
keys in the example aren't ideal,
but it makes it easy to read the example.
ParentTable (Key is composite of (State, CityName):
[State], [CityName], [Population]
AZ Phoenix 1,000,000
GA Phoenix 8,000
AZ Tucson 500,000
ChildTable (Key is SalesmanID. State and CityName are part of a composite
foreign key that referes to the ParentTable.
[SalesmanID], [State], [CityName], [DateAssigned]
1 AZ Phoenix 1/15/2006
1 AZ Tucson 3/01/2006
3 GA Phoenix 1/15/2006
I want ChildTable.CityName to be a lookup possible values from ParentTable,
but I want the values shown in the lookup
to be restricted based on the State entered in the column ChildTable.State.
For example,
if you were in either of the first two rows of ChildTable, and hit the drop
down, you should see
'Phoenix' and 'Tucson'. If you were in the third row, you should only see
'Phoenix', but it would
be the Phoenix with a population of just 8,000 people.
If I define the column ChildTable.CityName as a lookup, I always see the
values Phoenix, Phoenix, Tucson, regardless
of which row I am on in Childtable.
How do I define the lookup so that the value from ChildTable is part of the
WHERE clause in the query that gets data
from ParentTable to populate the listbox? In other words, I want the query
to say WHERE State = 'AZ' when someone
invokes the lookup from one of the first two rows in ChildTable.
Thanks,
Mac