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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

whileprintingrecords help

Status
Not open for further replies.

tonyvee1973

IS-IT--Management
Oct 22, 2009
156
GB
Hi
I have a report which uses a "Whileprintingrecords" formula - I only need to show results that are greater than zero but am going around in circles. I've placed the formulas below, any help really would be appreciated.

(The formula for the field which i only to show results which are greater than zero - this is called {@printrunphysical})
// Prints the recalculated 'As At' value for Physical quantity
whileprintingrecords;
numbervar RunPhysical;

(The runphysical formula)
// Calculate the Physical 'AS AT' value starting with the most recent movement back to the oldest (After 'As At' Date)

Whileprintingrecords;
Numbervar RunPhysical;
If {STK_MOVEMENTS.SM_DATE} > {?Report Date} And {STK_MOVEMENTS.SM_STATUS} = 'I'
Then
RunPhysical := RunPhysical - ({STK_MOVEMENTS.SM_QUANTITY}*{STK_MOVEMENTS.SM_QTYUNIT})

Else
If {STK_MOVEMENTS.SM_DATE} > {?Report Date} And {STK_MOVEMENTS.SM_STATUS} = 'O'
Then
RunPhysical := RunPhysical + ({STK_MOVEMENTS.SM_QUANTITY}*{STK_MOVEMENTS.SM_QTYUNIT})

Else
RunPhysical := RunPhysical
 
What do you need? You don't explain the difference between what the formulas should do and what they actually do.

I'd also suggest starting again, using regular formula fields and automatic totalling rather than variables. Let Crystal do most of the work. (If you're not already familiar with Crystal's automated totals, see FAQ767-6524.)

First define movement:
Code:
{STK_MOVEMENTS.SM_QUANTITY}*{STK_MOVEMENTS.SM_QTYUNIT}
Display this at a detail line level - see if you have any nulls, which might be a cause of problems.

Then do a pair of running totals, you get them by right-clicking on the field. One for @MovementIn and the other for @MovementOut. SHow these also, confirm they work. And total by group, whatever you are grouping by, or wish to show the totals for.

Presumably you just wish to show those where @MovementIn minus @MovementOut is positive. An easy test.

Once you have that, you can suppress details etc. and just show the result. But it's mostly better to show things by stages, rather than trying to go direct to an end result and then trying to figure if it is wrong.

PS. It helps to give your Crystal version - 8, 8.5, 9, 10, 11, 2008 or whatever. Methods sometimes change between versions, and higher versions have extra options. In this case, it probably makes no difference.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Sorry, am using Crystal XI on WIndows 7.

Dont think i am able to rebuild the whole thing, its pretty complex as i havent done much crystal report work.
The results i am getting is that the {@printrunphysical} is giving me all results where i just want it to return results greater than zero. If it was a normal formula this would be fine, just where its a "Whileprintingrecords" one.
I have attached image to help explain, thanks
 
 http://www.mediafire.com/i/?k1c9a16648ish1b
Right click on the formula->format field->number->customize->check "suppress if zero".

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top