Tina K
asked on
Crystal Reports Sub-report formula
Hello all -
I've created a report that we use for counting inventory in a warehouse environment. The main report takes the location parameter, adds titles, displays how many locations are being counted, and also a running total of how many individual parts were counted, based on a variable formula from the subreport. I had this all working great until we realized that locations without inventory were not being shown, so I remedied that by removing the part.qty>0 from just the main report, but leaving on the subreport, which shows the actual part numbers and piece counts of the location.
Works great, but the formula is adding the value from the last location for each subreport, even if there are no records in the subreport:
You can see that the "Running total of parts counted" is adding 5 for each instance of the subreport, when it should not be. How do I make this go away?
Here's how the formulas work:
In subreport:
formula @subtot2 (in report footer, hidden)
shared numbervar subtot1;
subtot1:= sum({command.part_qty});
In main report:
formula @grandtot (in group footer)
shared numbervar subtot1;
subtot1;
numbervar x;
x:= x+subtot1
Like I said, everything works exactly how I need with the exception of the 'bonus' addition.
Thanks in advance!
I've created a report that we use for counting inventory in a warehouse environment. The main report takes the location parameter, adds titles, displays how many locations are being counted, and also a running total of how many individual parts were counted, based on a variable formula from the subreport. I had this all working great until we realized that locations without inventory were not being shown, so I remedied that by removing the part.qty>0 from just the main report, but leaving on the subreport, which shows the actual part numbers and piece counts of the location.
Works great, but the formula is adding the value from the last location for each subreport, even if there are no records in the subreport:
You can see that the "Running total of parts counted" is adding 5 for each instance of the subreport, when it should not be. How do I make this go away?
Here's how the formulas work:
In subreport:
formula @subtot2 (in report footer, hidden)
shared numbervar subtot1;
subtot1:= sum({command.part_qty});
In main report:
formula @grandtot (in group footer)
shared numbervar subtot1;
subtot1;
numbervar x;
x:= x+subtot1
Like I said, everything works exactly how I need with the exception of the 'bonus' addition.
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just had a thought. You could also do it in the grandtotal formula
mlmcc
shared numbervar subtot1;
subtot1;
numbervar x;
x:= x+subtot1;
subtot1 := 0;
x
mlmcc
ASKER
Thank you mlmcc - perfect solution!
ASKER
Location-Snap-2.pdf