Hi All,

Back again looking for some help and guidance, I have a recordset and I want to loop through this recordset until I find the field with the highest date. I am have a basic knowledge of how it should work but I have no idea what way to express the condition that means do until lastdate . I am not to sure how clear I am being but any help would be appreicated as always.

This is all I got so far

Do While Not rs.EOF And (rs!NEXTDUEDATE > PNUM(2,ctr))
    Let PNUM(1, ctr) = rs!LastOfEMPCODE
    Let PNUM(2, ctr) = rs!NEXTDUEDATE
    Let PNUM(3, ctr) = rs!LASTPERFDATE
    Let PNUM(4, ctr) = Eqnum
    rs.MoveNext
    Let ctr = ctr + 1
  Loop

Rgds

Nora.

Hi,

Try this :

Do While Not rs.EOF 
    Let PNUM(1, ctr) = rs!LastOfEMPCODE
    Let PNUM(2, ctr) = rs!NEXTDUEDATE
    Let PNUM(3, ctr) = rs!LASTPERFDATE
    Let PNUM(4, ctr) = Eqnum
    '
    rs.MoveNext
    Let ctr = ctr + 1
    If (rs!NEXTDUEDATE > PNUM(2,ctr)) Then 
        Exit Do
    End If
  Loop

Regards
Veena

Thanks very much for your help but I have encountered a problem, if there is more than one record it works fine, but on occasion there may be a new item which would only have one record in this instance an error is created. Would it be possible to add a statement that will prevent the error when only one record is encountered.

Tried adding this but it wasn't any good. Again your help is appreciated.

Do While Not rs.EOF
Let PNUM(1, ctr) = rs!WONUM
Let PNUM(2, ctr) = rs!COMPLETIONDATE
Let PNUM(3, ctr) = rs!EMPCODE
Let PNUM(4, ctr) = Eqnum
'
rs.MoveNext
Let ctr = ctr + 1
If ctr > 1 Then
If (rs!COMPLETIONDATE > PNUM(2, ctr)) Then
Exit Do
End If
End If
Loop

Hi,

Try this :

Do While Not rs.EOF
Let PNUM(1, ctr) = rs!WONUM
Let PNUM(2, ctr) = rs!COMPLETIONDATE
Let PNUM(3, ctr) = rs!EMPCODE
Let PNUM(4, ctr) = Eqnum
'
rs.MoveNext
Let ctr = ctr + 1
If ctr > 1 And Not rs.EOF Then
If (rs!COMPLETIONDATE > PNUM(2, ctr)) Then
Exit Do
End If
End If
Loop

REgards
Veena

Thanks a lot, finally got it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.