By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,404 Members | 2,300 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,404 IT Pros & Developers. It's quick & easy.

Recordset not looping

P: 26
Hi guys,

I have a problem with a dao recordset in that it won't loop my code through all the records - it only runs the loop code on the first record...

Here is the code:

Dim dbs As dao.Database
Dim rst As dao.Recordset
Dim strSQL As String

Set dbs = CurrentDb
strSQL = "Select * FROM [MNT-CORE COMPETENCIES]"
Set rst = dbs.OpenRecordset(strSQL)
rst.MoveFirst
rst.MoveLast
Dim twomonthsuntildue As Date
Do While Not rst.EOF And Not rst.BOF
rst.Edit
If Date >= [PERFORMANCE APPRAISAL DUE] Then
[DUE?] = True
Else
[DUE?] = False
End If
twomonthsuntildue = DateAdd("m", 2, Date)
If twomonthsuntildue >= [PERFORMANCE APPRAISAL DUE] Then
[duewithinonemonth] = True
Else
[duewithinonemonth] = False
End If
If [DUE?] = True Then
[duewithinonemonth] = False
End If
rst.Update
rst.MoveNext
Loop

Thanks in advance guys.

Chris
Sep 13 '07 #1
Share this Question
Share on Google+
2 Replies


Scott Price
Expert 100+
P: 1,384
Expand|Select|Wrap|Line Numbers
  1. Dim dbs As dao.Database
  2. Dim rst As dao.Recordset
  3. Dim strSQL As String
  4.  
  5. Set dbs = CurrentDb
  6. strSQL = "Select * FROM [MNT-CORE COMPETENCIES]"
  7. Set rst = dbs.OpenRecordset(strSQL)
  8. rst.MoveFirst
  9. rst.MoveLast
  10. Dim twomonthsuntildue As Date
  11. Do While Not rst.EOF And Not rst.BOF
  12. rst.Edit
  13. If Date >= [PERFORMANCE APPRAISAL DUE] Then
  14. [DUE?] = True
  15. Else
  16. [DUE?] = False
  17. End If
  18. twomonthsuntildue = DateAdd("m", 2, Date)
  19. If twomonthsuntildue >= [PERFORMANCE APPRAISAL DUE] Then
  20. [duewithinonemonth] = True
  21. Else
  22. [duewithinonemonth] = False
  23. End If
  24. If [DUE?] = True Then
  25. [duewithinonemonth] = False
  26. End If
  27. rst.Update
  28. rst.MoveNext
  29. Loop
On line 11, try changing to this:
Expand|Select|Wrap|Line Numbers
  1. Do While Not rst.EOF
Regards,
Scott
Sep 13 '07 #2

FishVal
Expert 2.5K+
P: 2,653
And get rid of line #9. Or at least place it before line #8. ;)

Regards,
Fish
Sep 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.