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

Code instead of Next(Next())

Status
Not open for further replies.

Genepoz

Technical User
Aug 7, 2001
38
US
CR XI R2: I need code that would do the job of Next(Next()) (which obviously doesn't work).
I'm sure it's some For/Do While but I'm not good at those yet. What I have now is

If Next({Table1.Field2})>0 Then ToText({Table1.Field2}) Else ""

This looks at the next record, but I need to look at the next one after that. If the next record is >0 it will be 1; if the next record after that is >0 it will be 2.

Thanks in advance. Sorry this is such a basic question
 
I think you should explain what you are hoping the "next next code" will do for you--what is the purpose of the report? What does this count tell you? There is probably another way to handle this. It would help also to see some sample data.

-LB
 
The report query produces a "Callee" table (which works fine) and a "Caller" table like this:

Order Caller Alt
1 Smith 0
1 Jones 1
1 White 2
2 Jones 0
3 Posey 0
3 Black 1
4 Green 0

My report looks like this:

Group Header 1: {Caller Alt 0} & {Caller Alt 1} & {Caller Alt 2}
Group Header 2: {Person being called}
Detail: (Suppressed)
Group Footer 2: (Suppressed)
Groups Footer 1: (Suppressed)

What I have now in Group 1 formula is

{Caller Alt 0} & (If Next({Alt})>0 Then Next (Caller) & ToText(Next({Alt})) Else "")

This gives me the primary caller and looks at the next record, giving me the Alt 1 caller, but I need to look at the next one after that.
 
But what field are you actually grouping on for Group #1? You can't group on a formula that contains the next function. Assuming your group is simply on Order, you could add a crosstab in the group header that uses order as the row field and alt as the column field, using maximum of alt as the summary. Then suppress the labels and remove the grid.

Another option would be to insert a subreport linked on order, and then collect the alt values in a variable to display in the subreport footer, and then suppress all else in the sub except the footer.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top