Click to See Complete Forum and Search --> : Table linking - Preventing duplicate detail lines


andyrey1977
September 18th, 2006, 10:38 AM
Using Crystal Reports v.10
I have 2 tables that look like the following:
----Order_Table----
Line Product qty
1 cup 3
2 tea bag 4
3 cup 1

--Stock_Allocation_table--
product order_qty ref
cup 1 1
cup 2 4
cup 1 8
tea bag 1 9
tea bag 1 10
tea bag 1 12
tea bag 1 18

when linking the tables I get the following:

Line product order qty ref
1 cup 1 1
1 cup 2 4
1 cup 1 8
total 4
2 tea bag 1 9
2 tea bag 1 10
2 tea bag 1 12
2 tea bag 1 18
total 4
3 cup 1 1
3 cup 2 4
3 cup 1 8
total 4

As I have no direct link between the order table line field and the stock allocation table, and am only able to link using the product ID, it is duplicating the stock allocation lines on each "cup" order line. What I would like is the following:

Line product order qty ref
1 cup 1 1
1 cup 2 4
total 3
2 tea bag 1 9
2 tea bag 1 10
2 tea bag 1 12
2 tea bag 1 18
total 4
3 cup 1 8

I am pretty new to crystal, but guess I need to use a running total so that when the stock_allocation_table.order_qty of the detail lines reaches the order_table.qty, it moves onto the next group. I do not know how to do this, also do not know how to prevent specific lines from the stock allocation table being used more than onece in each order.
Any help would be appreciated!!!

Ta
Andy

sweet_babylhyn
September 18th, 2006, 11:56 PM
I think u must insert another field in Stock_Allocation_table name "Line".
This will be the link in your 2 table. As you can see, there is a duplicate record in your order table("cup"). So when you link the 2 table, it will return two output. 3 records for the 1,cup,3 and 3 records also for 3,cup,1

OK!