How to Nest For, Do Until loop?

  • Thread starter Thread starter deko
  • Start date Start date
D

deko

This code does not compile - the error rec'd says "Next without For"

For Each olmi In olfsm.Items
rstS.MoveFirst
Do Until rstS.EOF
If Not IsNull(rst!strS) Then 'I want to check each item in
recordset that is not null
If (InStr(olmi.To, rst!srtS)) > 0 Then
rst.AddNew
rst!DateSent = olmi.SentOn
rst!Subject = olmi.Subject
rst!Recipient = olmi.To
rst.Update
End If
End If
rstS.MoveNext
Next

where am I going wrong? Is it possible to nest a Do Until inside a For
loop?
 
Yes, but you need some terminating statement for your Do loop:

rstS.MoveNext
Loop
Next
 
deko said:
This code does not compile - the error rec'd says "Next without For"

For Each olmi In olfsm.Items <----------------------------+
rstS.MoveFirst |
Do Until rstS.EOF |
If Not IsNull(rst!strS) Then 'I want to check each item |
in recordset that is not null <-----------------+ |
If (InStr(olmi.To, rst!srtS)) > 0 Then <----+ | |
rst.AddNew | | |
rst!DateSent = olmi.SentOn | | |
rst!Subject = olmi.Subject | | |
rst!Recipient = olmi.To | | |
rst.Update | | |
End If <-----+ | |
End If <-----------------+ |
rstS.MoveNext |
<----------------------------+

where am I going wrong?

It appears as though you do not have the ending indicator for the Do Until.
--
Brian Tillman
Smiths Aerospace
3290 Patterson Ave. SE, MS 1B3
Grand Rapids, MI 49512-1991
Brian.Tillman is the name, smiths-aerospace.com is the domain.

I don't speak for Smiths, and Smiths doesn't speak for me.
 
Back
Top