I have the following code that works, but is extremely slow, b/c dealing with at least 5000 to 6000 accounts. Also, the number of accounts will grow each time, so the next time, there will be probably 11,000 + accounts, and then 16000 or 17000 accounts total the next time, so I really need to use some kind of VB code or SQL code in order to find the first instance, set the recordset to that record, and do the remaining code for the records that meet the criteria (current date), but only start at the first instance - or whatever will work quickly. Again, current code works, but VERY SLOW!!!
Any help/advise would be greatly appreciated. I would think that it would be best to use SQL somehow in this to make it quicker, but I'm not exactly a veteran at all of this.
Thanks in advance,
Stephen
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
Code:
Option Compare Database
Option Explicit
Private Sub Count()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblHistoricalbyBatch")
Dim intCount As Integer, I As Integer, intAccount As Integer
rs.MoveFirst
intAccount = 0
Do While Not rs.EOF
If rs!DateUpdated = Date Then
intCount = 0
With rs
I = 7
For I = 7 To 12
If rs(I) <> 0 Then
If rs(I) <> "" Then
intCount = intCount + 1
intAccount = intAccount + 1
End If
End If
Next
.Edit
![#Payments] = intCount
.Update
.MoveNext
End With
End If
Loop
MsgBox intAccount & " Accounts were updated."
End Sub
Any help/advise would be greatly appreciated. I would think that it would be best to use SQL somehow in this to make it quicker, but I'm not exactly a veteran at all of this.
Thanks in advance,
Stephen
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV