I posted a question earlier, thread705-848586 , where CajunCenturian offered some help in speeding up some code for searching and editing a large table. The following code is the code I ended up with:
The full error message I was given was this:
Run-time error '3052':
[BLUE]File sharing lock exceeded. Increase MaxLocksPerFile registry entry.[/BLUE]
The line of code that is highlighted when choose 'Debug' is:
[GREEN].Edit[/GREEN]
Also, here is what the helpfile says about the error:
My work computer is this:
Intel Pentium 4 @ 2.4Ghz (or 2.2Ghz)
1024 MB DDR SDRAM - not sure of the memory speed, pbbly PC266
64mb video card
40 Gig hard drive
Is on a Windows 2000 server system, I believe - don't think upgraded to 2003 yet.
Operating system is Windows 2000
Using Access 2002 w/VBA - no stand alone VB application.
Stephen![[infinity] [infinity] [infinity]](/data/assets/smilies/infinity.gif)
"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:
Private Sub CountPayments()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intCount As Integer, I As Integer, lngAccount As Long
Dim MyDate As Date
MyDate = "5/24/2004"
Set db = CurrentDb()
' Set rs = db.OpenRecordset("SELECT * FROM tblHistoricalbyBatch " & _
' "WHERE UpdateDate = #" & Date & "#;")
With rs
If rs.BOF And rs.EOF Then
MsgBox "No records in this file"
Else
.MoveFirst
lngAccount = 0
Do While Not .EOF
intCount = 0
For I = 7 To 12
intCount = intCount + Abs(Sgn(Nz(rs(I), 0)))
Next
.Edit
.Fields("#Payments") = intCount
.Update
.MoveNext
lngAccount = lngAccount + 1
Loop
End If
End With
Set rs = Nothing
MsgBox lngAccount & " Accounts were updated."
End Sub
Run-time error '3052':
[BLUE]File sharing lock exceeded. Increase MaxLocksPerFile registry entry.[/BLUE]
The line of code that is highlighted when choose 'Debug' is:
[GREEN].Edit[/GREEN]
Also, here is what the helpfile says about the error:
File sharing lock count exceeded. Increase MaxLocksPerFile registry entry. (Error 3052)
You have exceeded the maximum number of locks allowed on a recordset. This limit is specified by the MaxLocksPerFile setting in your system registry. The default value is 9500, and can be changed either by editing the registry with Regedit.exe or with the SetOption method.
Some other factors that may cause an application to reach this threshold include the following:
amount of available memory
size of rows in the recordset
network operating system restrictions
My work computer is this:
Intel Pentium 4 @ 2.4Ghz (or 2.2Ghz)
1024 MB DDR SDRAM - not sure of the memory speed, pbbly PC266
64mb video card
40 Gig hard drive
Is on a Windows 2000 server system, I believe - don't think upgraded to 2003 yet.
Operating system is Windows 2000
Using Access 2002 w/VBA - no stand alone VB application.
Stephen
![[infinity] [infinity] [infinity]](/data/assets/smilies/infinity.gif)
"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