473,378 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Recordset not looping

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
2 1348
Scott Price
1,384 Expert 1GB
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
2,653 Expert 2GB
And get rid of line #9. Or at least place it before line #8. ;)

Regards,
Fish
Sep 13 '07 #3

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

Similar topics

4
by: Thomas Scheiderich | last post by:
Why would you use the Recordset object over the Execute method of getting data from your Sql database. For example, I have the following: Execute Method...
4
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use...
5
by: !TG | last post by:
I currently use Do while loop, but I'd rather use a For Loop though I have never gotten the hang of them. Would some one please be so kind as to show me how to loop through a recordset.
3
by: Mika | last post by:
Is it possible to perform functions on a recordset (rather than on the source database), e.g. COUNT, MAX etc The reason I would like to do this is because I have a hugely complex view which...
4
by: Dalan | last post by:
I presume that using an open recordset method is the preferred method of accomplishing what I'm trying to do. Of course, if there are other options that would work, feel free to share them. I...
1
by: @ndy | last post by:
Hellow programmers, does anybody has any suggestions for the next problem? I'm looping a recordset and during the loop it allso calculate some things. Now I want display a POPUP FORM with...
13
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset of the companies in the database (found using the...
3
by: BillCo | last post by:
This worked for a large database (150+ tables): Do While Not rstLinks.EOF Set td = DB.TableDefs(rstLinks!Name) 'Debug.Print rstLinks!Name If InStr(td.Connect, "corpbe.mdb") Then td.Connect =...
3
by: mark_aok | last post by:
Hi all, All I am trying to do is open a table, edit it, and then close it. But I am having the strangest error. Here is my code Dim i as integer Dim rs as adodb.recordset Set rs = new...
10
by: akselo | last post by:
Hi folks, I am working on a routine that will select a sample of parcels from a table. Each parcel belongs to a census tract, and depending on which tract, a certain calculation is applied. The...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.