Rst.FindNext Loop

  • Thread starter Thread starter TC
  • Start date Start date
T

TC

Your instinct serves you well!

rs.findfirst ....
while not rs.nomatch
.....
rs.findnext ...
wend

HTH,
TC
 
Wta is the code structure to put Rst.FindNext in a loop? I'm using what I show
below. It works fine but my instinct says it should be in some standard loop
rather than using the GoTo structure.

RstTicket.FindFirst "[TicketID] = " & Me!TicketID
If RstTicket.NoMatch = False Then
<<Some Code>>

CheckForAnotherTicket:
RstTicket.FindNext "[TicketID] = " & Me!TicketID
If RstTicket.NoMatch = False Then
<<Some Code>>
GoTo CheckForAnotherTicket
End If
End If

Thanks for all help!!

Tom
 
Not quite ... (Please see my reply)

--
HTH
Van T. Dinh
MVP (Access)



TC said:
Your instinct serves you well!

rs.findfirst ....
while not rs.nomatch
.....
rs.findnext ...
wend

HTH,
TC


Tom said:
Wta is the code structure to put Rst.FindNext in a loop? I'm using what
I
show
below. It works fine but my instinct says it should be in some standard loop
rather than using the GoTo structure.

RstTicket.FindFirst "[TicketID] = " & Me!TicketID
If RstTicket.NoMatch = False Then
<<Some Code>>

CheckForAnotherTicket:
RstTicket.FindNext "[TicketID] = " & Me!TicketID
If RstTicket.NoMatch = False Then
<<Some Code>>
GoTo CheckForAnotherTicket
End If
End If

Thanks for all help!!

Tom
 
No, you don't need the loop. FindFirst actually means find the FIRST
instance / row that matches your criteria but it will search the WHOLE
Recordset if there is no match. Thus, if the FindFirst doesn't find the
matched Record / Row, your FindNext will NEVER find it either!
 
I disagree. He clearly wants to find a matching record (if any) with
FindFirst, then find subsequent matching records (if any) with FindNext. My
suggestion does that for him. The code that he used before, was wrong. He
*says* that it worked, but my bet is that it didn't.

Perhaps he could step in & clarify (if he's still reading this)?

TC


Van T. Dinh said:
Not quite ... (Please see my reply)

--
HTH
Van T. Dinh
MVP (Access)



TC said:
Your instinct serves you well!

rs.findfirst ....
while not rs.nomatch
.....
rs.findnext ...
wend

HTH,
TC
what
I
show
below. It works fine but my instinct says it should be in some
standard
loop
rather than using the GoTo structure.

RstTicket.FindFirst "[TicketID] = " & Me!TicketID
If RstTicket.NoMatch = False Then
<<Some Code>>

CheckForAnotherTicket:
RstTicket.FindNext "[TicketID] = " & Me!TicketID
If RstTicket.NoMatch = False Then
<<Some Code>>
GoTo CheckForAnotherTicket
End If
End If

Thanks for all help!!

Tom
 
Back
Top