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

Is there a formula to stop formula when the page turns?

Status
Not open for further replies.

kg2report

IS-IT--Management
Apr 5, 2018
25
0
0
US
Hi.

I was wondering if there is a way I can force the formula to not function for the next page or previous page. Any help would be greatly appreciated.


IF PageNumber > 0 then
Left ({table1_by_row.name_last}, 1)


Thanks.
kg
 
Hi LB.

I was wondering if you would kindly explain what each line does in the formula you provided below? I'm trying to learn more and would like to visualize what each line does in the process. Thanks. kg.

whileprintingrecords;
stringvar p;
numbervar i;
if remainder(i,40)=0 then(
i := 0;
p := "";
);


whileprintingrecords;
stringvar x;
numbervar i := i + 1;
stringvar p;

x := {User.name_last}[1];
if i = 1 then
p := x else
p := replicatestring(chr(9),i-1)+x;
p

 
Second formula first:

Whileprintingrecords - In most cases, if you are accumulating across records, it needs to occur on the second pass, or while printing records.

The numbervar and stringvar lines give the variables their names: x, i, p. You could name these anything you like.

The i variable is a count where 1 is added to the current value of i. Since this is in the page footer, it accumulates only when the page changes.

X:= {User.name_last}[1]; //This sets x equal to the first character in the name by using a subscript of 1.

The next lines say that if it is page 1, then a new string p is equal to the initial; if any other page, there will be one or more tabs corresponding to the number of the page minus 1, followed by the initial. Without the reset formula, this would keep wrapping and moving down the page (if you increased the height of the formula in the page footer to see it).

Reset formula: First you see the whileprintingrecords and the variables being referenced, and then the reset formula itself. It says when i reaches 40 (the right hand margin in your case), set i to 0 so that the next page i= 1 and the initial will appear on the left—as long as you also set p to the state of emptiness so that p does not instead wrap. The parentheses around both declarations make the remainder condition (the remainder of i divided by 40 = 0 which is the same as the pagenumber being perfectly divisible by 40) apply to both i and p.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top