Hello members
I reading - Looping through a recordset (MS Access Query) that has 49 records. Note: the query is generate on the fly(dynamically). The processing is supposed to exit the loop at EOF but it keeps processing indefinitely (sort of an infinite loop).
Does anybody know why this is happing?
See my module below:
Do Until M.qBW.EOF = True
xlWksht.Cells(ii, 1).Value = M.qBW![Req No]
xlWksht.Cells(ii, 2).Value = M.qBW![Description]
xlWksht.Cells(ii, 3).Value = M.qBW![ClientName] & Chr(10) & M.qBW![Status]
xlWksht.Cells(ii, 4).Value = M.qBW![P L] & Chr(10) & M.qBW![TotalProg1Hrs]
rsinPers.MoveFirst
Do Until rsinPers.EOF
If rsinPers![Name] = M.qBW![Personnel2] Then
xlWksht.Cells(ii, 5).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg2Hrs]
End If
rsinPers.MoveNext
Loop
rsinPers.MoveFirst
Do Until rsinPers.EOF
If rsinPers![Name] = M.qBW![Personnel3] Then
xlWksht.Cells(ii, 6).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg3Hrs]
End If
rsinPers.MoveNext
Loop
rsinPers.MoveFirst
Do Until rsinPers.EOF
If rsinPers![Name] = M.qBW![Personnel4] Then
xlWksht.Cells(ii, 7).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg4Hrs]
End If
rsinPers.MoveNext
Loop
rsinPers.MoveFirst
Do Until rsinPers.EOF
If rsinPers![Name] = M.qBW![Personnel5] Then
xlWksht.Cells(ii, 8).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg5Hrs]
End If
rsinPers.MoveNext
Loop
rsinPers.MoveFirst
Do Until rsinPers.EOF
If rsinPers![Name] = M.qBW![Personnel6] Then
xlWksht.Cells(ii, 9).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg6Hr]
End If
rsinPers.MoveNext
Loop
xlWksht.Cells(ii, 10).Value = "-" & Chr(10) & M.qBW.Fields("Per Hrs")
xlWksht.Cells(ii, 11).Value = M.qBW.Fields("EstimatedTotalHours") & Chr(10) & M.qBW.Fields("Tot Hrs")
xlWksht.Cells(ii, 12).Value = M.qBW![Start Date] & Chr(10) & M.qBW![Start Date]
xlWksht.Cells(ii, 13).Value = M.qBW![End Date] & Chr(10) & M.qBW![End Date]
xlWksht.Cells(ii, 14).Value = "Comments:" & Chr(10) & "'" & M.qBW![Comments]
recordcnt = M.qBW.RecordCount
Loop
Thanks,
tgifgemini