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

Returning info from line " 2 previous" for the current line 1

Status
Not open for further replies.
Dec 18, 2006
69
US
Hello everyone,

I am currently using Crystal XI professional. I stumble on the issue below and was wondering if anyone has any thoughts on how to resolve it.

I have a dataset that is sorted in descending order. I have qty on hand information that I want to print on the line below it. Here's an illustration:

QOH item ID prior QOH value transaction type
100 ABC
120 ABC 100 1 sales 1
150 ABC 120 1 sales 2
0 ABC 0 .5 acct adjustment
170 ABC 150 .4 sales 3

I had been using the PREVIOUS command successfully until I hit the acct adjustment (So the prior QOH uses the PREVIOUS command against QOH column). The acct adjustment type does not change any QOH information. It only changes the value. Thus, What I need is to have the prior QOH of sales 3 to be the QOH of sales 2. It is okay with me if the acct adjustment qty information to be the same as the qty information of sales 3. I need to skip the qty information every time I see acct adjustment.

I don't believe I can do previous within a previous. I am really stumped on this. If anyone can give me some pointers, I will greatly appreciate it.

Thanks in advance.

 
Try a formula like this to replace your current previous QOH formula:

whileprintingrecords;
numbervar prevqoh;
if previous({table.transactiontype}) <> "acct adjustment" then
prevqoh := previous({table.qoh}) else
prevqoh := prevqoh;

This would, however, show previous QOH as 150 for the acct adjustment line in your sample above, as well as 150 for sales3. You could format the display by right clicking on the formula-> format field->display string->x+2 like this:

if {table.transactiontype} = "acct adjustment" then
"0" else
totext(currentfieldvalue,0,"")

This only changes the display, not the underlying value.

-LB
 
lbass - you saved me again and again.
Thank you very much. Your formula works AWESOME!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top