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!

Loop through data entries?

Status
Not open for further replies.

Jezzamatez

Technical User
Dec 12, 2011
3
GB
Hi, I have a counter for how many consecutive shifts someone has worked and I'm trying to get the date of the first shift of the consecutive period by using the counter to go back through each record.

I'm guessing for each iteration of the loop it's assigning the same previous value to the variable instead of going back through x number of records.

Can anyone offer any suggestions?

whileprintingrecords;
numbervar ShiftCnt;
Numbervar i;
Datevar Start:={@Shift Date};

If {@ST&LC Combination} = previous({@ST&LC Combination})
and {@Weekending} <= previous({@Weekending}) + 7
then ShiftCnt:=ShiftCnt+1 else
ShiftCnt:=1;
For i:= 1 To ShiftCnt Do (Start:=Previous({@Shift Date}));
 
How about showing some mock dates of shifts for a couple of employees and then show what results you want to see.

-LB
 
I have one person who's worked the following dates:

09/10/2011,13/10/2011,14/10/2011,21/10/2011,22/10/2011,23/10/2011,25/10/2011,28/10/2011,29/10/2011,31/10/2011

02/11/2011,07/11/2011

01/12/2011,09/12/2011,11/12/2011,13/12/2011,16,12/2011,17/12/2011,18/12/2011,23/12/2011

As the last 8 shifts are all within 1 weekending they are counted as consecutive. I need to count backwards from the latest date to get the first date of the consecutive period.

If it helps it is from a Lotus Notes database.
 
Treat the elements as separate fields, Split({Raw.Data}, ",")[1] and so on. You'll also need use UBOUND to find the number of table elements.
Code:
if ubound(split({Raw.Data},",")) >= 2 then
split({Raw.Data},",")[2]
Code:
if ubound(split({Raw.Data},",:")) >= 3 then
split({Raw.Data},",")[3]


[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
I may have completely misunderstood what you're trying to do but I think your confusion may have come from how I've laid out the dates...

Each date is a field from an individual notes document for a shift that has been completed.

So I was trying to use a loop to cycle back through x number of documents to get the value of the field BookingDate for that document.

Sorry if I'm being confusing or misunderstanding.
 
Please show the content of your formulas within the formula. You can't go backwards throught the records, so you will have to sort dates accordingly and adjust your formula accordingly. It is also unclear whether you want just one date to result or a set of dates that include the beginning of each consecutive period.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top