My loop code is stuck. It only returns the first record. What am I missing?
:banghead:
:banghead:
Code:
Dim rs As DAO.Recordset
Dim asReturn As String
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Parts A")
'rs.MoveFirst
If Not (rs.EOF) = True Then
rs.MoveFirst
Do Until rs.EOF
asReturn = Mid(DLookup("doc_num_cd", "Parts A"), 2, 5)
MsgBox "Substring is " & asReturn
rs.MoveNext
Loop
Else
MsgBox "There are no records in the recordset."
End If
MsgBox "Finished looping through records."
rs.Close 'Close the recordset
Set rs = Nothing 'Clean up
Last edited by a moderator: