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 set a variable to zero before the next record 2

Status
Not open for further replies.

Jake1

MIS
Aug 6, 2001
13
0
0
US
I am working with a sql table that contains times of transports. I want to compare each record with the previous record to see if it occured with 30 minutes. I have the times coverted to seconds and have created a variable to examine the previous record against the present record. It appears to be carrying the values over from the previous evaluation (present time - previous time). I need to set it to back to zero after it does the evalutation or store the current pickup time of the present record in order to evaluate it against the next record. How do I do this?
 
1. You could use the Previous() function and avoid the need for a variable.

2. If you need to use the variable approach, you can create a formula to reset in the same section and ensure it evaluates after the formula for computing the difference
by using the EvaluateAfter() function (see online help).

Cheers,
- Ido ixm7@psu.edu
 
this is the appraoch I'd use if I have understood your problem.

@formula comparison

WhilePrintingRecords;
numberVar result := 0;

//this will not evaluate for the first record
if not PreviousIsNull ({Table.time}) then
result := {Table.time} - Previous({Table.time});

this is probably what you were doing before...if it is then perhaps you didn't have the "WhilePrintingRecords" line in.

BTW....whenever you have a formula problem. Give us the formula...the mind reading is so much easier that way :)

hope this helps...Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top