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

Beginning Balance Formula 2

Status
Not open for further replies.

blueboyz

Technical User
Sep 13, 2005
210
US
I am using Crystal Reports v9.

I am trying to create a report that will display a history of sales for a particular customer and inventory item.

The customer contracts with us to purchase so many pounds of item A for a specific period of time (i.e., two years).
My columns on the report are:
Beg. Balance (lbs)
Invoice Date
Delivery Location
Invoice #
Qty Shipped
Ending Balance (lbs)

I created a running total on the Qty Shipped, so I could subtract the running total Qty Shipped from the Beg. Balance to get the Ending Balance.
My problem is that I don't have a way to get started with the beginning balance so that each row displays a new beginning and ending balance.
I am using a parameter to enter the Beginning Balance contract quantity {?Beg Balance}. How do I get the report to flow so that the Ending Balance on Row 1 now becomes the Beginning Balance on Row 2 and so on?
Beg Bal Date Inv Qty End Bal
800,000 9/14/04 4618 40,000 760,000
760,000 9/30/04 4678 10,000 750,000
750,000 10/11/04 4719 20,000 730,000

My Ending Balance formula is {?Beg Balance} - {#RT Quantity}. I only need to use the Beg Balance parameter in the first row; for rows 2 and up I need to use the Ending Balance formula.

 
Create a formula in the report header of:

whileprintingrecords;
numbervar BegBal := {?MyParmBeginningBalance}

Now you can reference the variable in the details to determine the end balance, just adjust the beginning balance accordingly (which is always the last ending blance):

Begbal formula:
whileprintingrecords;
numbervar BegBal;
Begbal

evaulateafter(@begbal)
numbervar BegBal;
Begbal:=Begbal-{table.qty};
Begbal

No we've used begbal as the endval after adjusting it, and it's ready for the next formula, the key was to use evaluateafter.

-k
 
K:

I tried your formula but I am getting an error that the remaining text does not appear to be part of the formula.

Here's what I have for the formula:
whilprintingrecords;
numbervar BegBal;
Begbal

evaluateafter
numbervar BegBal;
Begbal := BegBal - {#RT Quantity};
Begbal

I also tried
evaluateafter{@BEGBAL}
etc.

Can you tell me the correct syntax?
 
Sorry, you need a semi-colon after the evaluateafter, as in:

evaluateafter({@BEGBAL});
numbervar BegBal;
Begbal := BegBal - {#RT Quantity};
Begbal

-k
 
I tried putting the semicolon at the end of the "evaluateafter line", but I still get the same error (that the remaining text does not appear to be part of the formula).

Here's what I have for the formula called New Ending Bal:

whilprintingrecords;
numbervar BegBal;
Begbal

evaluateafter({@BEGBAL});
numbervar BegBal;
Begbal := BegBal - {#RT Quantity};
Begbal
 
These are two separate formulas:

//{@BegBal}:
whilprintingrecords;
numbervar BegBal;
Begbal

//{@NewBal}:
evaluateafter({@BEGBAL});
numbervar BegBal;
Begbal := BegBal - {#RT Quantity};
Begbal

-LB
 
My apologies for not clarifying this, you have one which computes begbal, then another which references begbal. If a formula tried to not evaluate until after itself ran, the Universe would reset, so please don't do that.

-k

 
Thank you LB and K.

I got CR to accept the evaluateafter formula. Now, I guess I have another issue. The report is not picking up the beginning number and I don't know how to display it on the report.

This is what I want the report to show:
Beg Bal Date Inv Qty End Bal
800,000 9/14/04 4618 40,000 760,000
760,000 9/30/04 4678 10,000 750,000
750,000 10/11/04 4719 20,000 730,000

When the user runs the report they are prompted to enter the Beginning Balance, i.e., 800,000.
However, when I preview the report I am showing:
Beg Bal Date Inv Qty End Bal
760,000 9/14/04 4618 40,000 760,000
720,000 9/30/04 4678 10,000 750,000
710,000 10/11/04 4719 20,000 730,000

The field I have in the details is the {@New Beg Bal} which is:

evaluateafter({@BEGBAL});
numbervar BegBal;
Begbal := BegBal - {#RT Quantity};
Begbal

This is the field that shows, 760,000 in the first row, 720,000 in the second row and 710,000 in the third row.

Is there a way I can start my Beg Bal column with the number that is entered in the parameter in the first row?



 
There are 3 formulas used:

Report Header:
whileprintingrecords;
numbervar BegBal := {?MyParmBeginningBalance}

Begbal formula: (Details section)
whileprintingrecords;
numbervar BegBal;
Begbal

End balance (Details section)
evaulateafter(@begbal)
numbervar BegBal;
Begbal:=Begbal-{table.qty};
Begbal

So the first detail record should be what is in the parameter for the BEGBAL formula.

If you're going to post what you used, show ALL of the formulas you used, not just one, otherwise you make us guess at everything else.

-k
 
I tried it, it appears there were some typos, try:

Initialize formula (Report Header):
whileprintingrecords;
numbervar BegBal := {?MyParmBeginningBalance}

Begbal formula: (Details section)
whileprintingrecords;
numbervar BegBal;
Begbal

End balance (Details section)
evaluateafter(@begbal)
numbervar BegBal;
Begbal:=Begbal-{table.qty};
Begbal

Worked fine here.

-k
 
That was the ticket. Thank you.

I didn't have the Begbal formula in the Details section under the first column. I was trying to use the End balance formula, instead. Once I changed it to the Begbal formula it worked like a charm. Thanks so much for sticking with me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top