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!

Creating for next loop/do while loop in Crystal Reports

Status
Not open for further replies.

KM1966

Technical User
Sep 9, 2020
1
US
I need to select the closest value from a list of values. For instance, I have 5,565 and need to select the appropriate value (rounding up) from the list below:

100
2,204
4,500
10,000

The value that I would select would be 10,000.
I need a formula that loops through the list of values and assigns the appropriate one to a variable.



 
Where is the 5565 coming from? Is it a field? Does the list of values you show represent different rows of the same field? Not sure why you need to assign the desired number to a variable. Not enough info to understand why you think you need a loop. You could just use a formula like this (Here I am assuming 5565 is derived from a parameter {?Val}:

Whileprintingrecords;
Numbervar x;

If not onlastrecord and
{table.field}<{?Val} and
Next({table.field})>{?Val} then
x := Next({table.field})

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top