Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Parameters 1

Status
Not open for further replies.

blueboyz

Technical User
Sep 13, 2005
210
US
I'm using Crystal Reports v9.
I am creating a report to display the components of assembly items ordered and what shortages there are for these components.

I have a parameter for the user to enter multiple discrete values for the assemblies ordered {?assembly id}.
I have another parameter for the user to enter the number of assemblies ordered for each assembly id
{?units ordered). The user can enter multiple discrete values.

Some assemblies have the same components as other assemblies.

The report groups on the components so it can subtotal the number of components needed, display what's in stock and report any shortages.

Report for Assembly 1, Assembly 2 and Assembly 3

Component
Qty Needed
Qty on Hand
Shortage (Qty Needed - Qty on Hand)

Lets say Assembly 1 has Components A, B and C
Assembly 2 has Components B, C, D and E
Assembly 3 has Components A, D and F
Only 1 unit of component A is needed for Assembly 1
2 units of component A is needed for Assembly 3
All others are 1 unit of the component needed

If the user enters Assembly 1, Assembly 2 and Assembly 3 for the parameter {?assembly id} and then enters 1, 2, 1 for the {?units ordered}then I want the report to display:

Component: A
Qty Needed: 3
Qty on Hand: 1
Shortage: 2

Component: B
Qty Needed: 3
Qty on Hand: 5
Shortage: 0

Component: C
Qty Needed: 3
Qty on Hand: 2
Shortage: 1

Component: D
Qty Needed: 2
Qty on Hand: 2
Shortage: 0

Component: E
Qty Needed: 2
Qty on Hand: 8
Shortage: 0

Component: F
Qty Needed: 1
Qty on Hand: 2
Shortage: 0

What is happening is the reports adds the units ordered as 4 and then shows:

Component: A
Qty Needed: 12
Qty on Hand: 1
Shortage: 11

Component: B
Qty Needed: 2
Qty on Hand: 5
Shortage: 0

Component: C
Qty Needed: 3
Qty on Hand: 2
Shortage: 1

Component: D
Qty Needed: 2
Qty on Hand: 2
Shortage: 0

Component: E
Qty Needed: 2
Qty on Hand: 8
Shortage: 0

Component: F
Qty Needed: 1
Qty on Hand: 2
Shortage: 0

Is there a way to link the parameter for units ordered {?units ordered} to each assembly entered {?assembly id}, so that if user enters Assembly 1, Assembly 2 and Assembly 3 and then enters 1, 2 and 1 for units needed, the report knows that 1 unit of Assembly 1 is needed, 2 units of Assembly 2 is needed and 1 unit of Assembly 3 is needed?
 
You could use a formula like the following in the detail sectioin:

numbervar i;
numbervar j := ubound({?assemblyID});
numbervar k;

for i := 1 to j do(
if {?assemblyID} = {table.assemblyID} then
k := {?units ordered});
k

If you have a group on component, you could then insert a summary (sum) on this formula at the group level.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top