J
Jesse
I am trying to write a query in Access 2000 and would appreciate some
guidance as to how this should be approached. I am at a very basic
skill level.
My goal is to create a query that determines what type and size of
packaging should be used depending on the mix of products purchased.
We know that if 3 products from category X and 7 from category Y are
purchased then 'the medium corrugated box' should be used (and we have
reduced this to a grid), but we would like the process automated so
that a simple list can be printed.
Simplified (but hopefully adequate): I have 2 tables (Tb1 and Tb2)
with 4 related integer fields - Tb1.t1 - Tb1.t4 and Tb2.c1 - Tb2.c4
(respectively). Tb1 is a transaction table with a field holding a
unique order_ID number and totals for how many products were purchased
in 4 categories (t1 - t4).
Tb2 is a catalog with 4 fields (c1 - c4) showing permutations of what
someone might buy, by category. There are also 2 non-unique tag
fields, tg1 and tg2. tg1 holds a tag from a list of 6 tags (types
of shipping containers) and tg2 holds a tag from a different list of 4
tags (container size). (There are additional fields in each table.)
The query output should include the order_ID and t1-t4 fields from
Tb1, and 2 calculated fields (f1 and f2) based on tg1 and tg2 from
Tb2.
For every record in Tb1 I want a lookup done in Tb2. The first record
in Tb2 where t1=c1 AND t2=c2 AND t3=c3 AND t4=c4 match, the
corresponding tg1 and tg2 tags should be generated for f1 and f2.
However, if there is no record in Tb2 that matches a given record in
Tb1 (for all of the 't' and 'c' fields), then 'No tg1' and 'No tg2'
should appear in that record's f1 and f2 fields. In other words,
every record from Tb1 should appear in the query output.
My attempts so far have resulted in query results that either have
multiple appearances of records from Tb1 or that do not show the
records from Tb1 that have no match in Tb2. So, suggestions? Thank
you. -- Jesse
guidance as to how this should be approached. I am at a very basic
skill level.
My goal is to create a query that determines what type and size of
packaging should be used depending on the mix of products purchased.
We know that if 3 products from category X and 7 from category Y are
purchased then 'the medium corrugated box' should be used (and we have
reduced this to a grid), but we would like the process automated so
that a simple list can be printed.
Simplified (but hopefully adequate): I have 2 tables (Tb1 and Tb2)
with 4 related integer fields - Tb1.t1 - Tb1.t4 and Tb2.c1 - Tb2.c4
(respectively). Tb1 is a transaction table with a field holding a
unique order_ID number and totals for how many products were purchased
in 4 categories (t1 - t4).
Tb2 is a catalog with 4 fields (c1 - c4) showing permutations of what
someone might buy, by category. There are also 2 non-unique tag
fields, tg1 and tg2. tg1 holds a tag from a list of 6 tags (types
of shipping containers) and tg2 holds a tag from a different list of 4
tags (container size). (There are additional fields in each table.)
The query output should include the order_ID and t1-t4 fields from
Tb1, and 2 calculated fields (f1 and f2) based on tg1 and tg2 from
Tb2.
For every record in Tb1 I want a lookup done in Tb2. The first record
in Tb2 where t1=c1 AND t2=c2 AND t3=c3 AND t4=c4 match, the
corresponding tg1 and tg2 tags should be generated for f1 and f2.
However, if there is no record in Tb2 that matches a given record in
Tb1 (for all of the 't' and 'c' fields), then 'No tg1' and 'No tg2'
should appear in that record's f1 and f2 fields. In other words,
every record from Tb1 should appear in the query output.
My attempts so far have resulted in query results that either have
multiple appearances of records from Tb1 or that do not show the
records from Tb1 that have no match in Tb2. So, suggestions? Thank
you. -- Jesse