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

How to get "Next Next" Value?

Status
Not open for further replies.

LWTri

Programmer
Jul 13, 2006
45
US
Hello, I'm reopening an OLD THREAD that I had not finished: How to get "Next Next" Value?

HISTORY:
_____________________________________________________________________________________________________________________

LWTri (Programmer) 30 Dec 08 14:59
Hey all, we're using Crystal XI. Does anyone know how to grab values from "future" records?

(1) We know how to grab the "next" value from next record:

Example Formula (@NextDate):
Next({table.date})

(2) But how do you grab values from future records (ex: 2 or 3 records later)? EX: We need the date from 2 records later.

(3) Tried using Next(Next({table.field})) and that doesn't work.

(4) Tried creating a formula that prints date where RecordCount + 2, but that doesn't work with regular EvaluationTime. Might work if we can use

WhilePrintingRecords or EvaluateAfter functions?

Any ideas would be greatly appreciated. Thanks!
_____________________________________________________________________________________________________________________

IdoMillet (Instructor) 30 Dec 08 22:56
afaik, can't be done.

- Ido
_____________________________________________________________________________________________________________________

lbass (TechnicalUser) 31 Dec 08 17:04
Try providing some sample data and explaining what you are trying to do. There might be an alternative method. You might be able to use

something like Nthlargest(3,{table.date}), for example.

-LB
_____________________________________________________________________________________________________________________
 
Here is an example of what I'm trying to do. There is NO SORT ORDER. This is a raw dump of data from database. For each record, we're trying to also display the "Next Next" CaseDate (CaseDate from two records later), using a formula. NthLargest function unfortunately won't work because we don't want an Nth Largest date...it needs to be from the "next next" record. Thanks for any input!



Case# CaseDate Doc Next Next Next
___________________________________________________________________________________________________
103536 12/25/2009 12:00:00 AM Wang, Mary MD 12/25/2009 12:00:00 AM 12/29/2009 12:00:00 AM
103537 12/25/2009 12:00:00 AM Singh, Andy MD 12/29/2009 12:00:00 AM 12/30/2009 12:00:00 AM
103672 12/29/2009 12:00:00 AM James, Sue MD 12/30/2009 12:00:00 AM 12/30/2009 12:00:00 AM
103705 12/30/2009 12:00:00 AM Nguyen, Jane MD 12/30/2009 12:00:00 AM 12/25/2009 12:00:00 AM
103706 12/30/2009 12:00:00 AM Johnson, Bob MD 12/25/2009 12:00:00 AM 12/25/2009 12:00:00 AM
103539 12/25/2009 12:00:00 AM Chen, Joe MD 12/25/2009 12:00:00 AM 12/26/2009 12:00:00 AM
103540 12/25/2009 12:00:00 AM Joyce, Jim MD 12/26/2009 12:00:00 AM 12/27/2009 12:00:00 AM
103553 12/26/2009 12:00:00 AM Black, Jill MD 12/27/2009 12:00:00 AM
103554 12/27/2009 12:00:00 AM White, Lisa MD
 
Try a subreport, to read two records ahead and either display the value or return it using Shared Variables. Inefficient, but I see no other way to do it in Crystal.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
If you can sort in descending order by date, I think you can do this with a formula. Would that be acceptable? Do you mean to do this within some group?

-LB
 
Thanks for everyone's input!

Madawc - I'll try a subrpt method and see if it works out.

Lbass - Unfortunately, we're not sorting the data. It's just a raw dump. I'm not certain if we'll be using a group (requestor won't be back till next week). What are your ideas for method within a group (ex: group by Doc) or without a group?
 
This seems like a very odd request--just out of curiosity, how will the requestor use this info? What will it tell the requestor?

You can do this with subreports by using > links instead of = links. Make sure the subreport selection formulas both read:

{table.case#} > {?pm-table.case#}

Also add a sort order to each sub based on {table.case#}. Then in the first sub, add the datetime field to the report header and suppress the rest of the report. In the second sub, create a formula and add it to the report header and suppress the rest of the report:

next({table.datetime})

-LB
 
Hi lbass, thanks so much for your input.

My teammate changed approach on how to attack the report. Turns out that the data had a "STEP" field (Step A, Step B, Step C, Step D, Step E). Under each Case# group, the 5 records were sorted in same descending order by Step. He needed to diplay the Date for Step E (from record 1), Date for Step D (from record 2), Date for Step C (from record 3), Date for Step B (from record 4), and Date for Step A (from record 5) in the Group Header. That's why he was trying to grab the Next Date, Next Next Date, Next Next Next Date, etc. Instead of doing that, he realized how to use Global Variables to store and carry down each of the specific dates into the Group Footer. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top