Hi all. The code I run below runs perfectly in cases where I have a small amount of records. However, in cases were I have several thousands of records, the code only partially runs before giving me the error message of:
For my case, the "SetOption method" sound like the way I want to go since I do not want to mess with my system registry. Does anyone know how to impliment this in my code below? Or maybe there's some simple refinements that need to be made to the code itself. I'm guess ADezii will probably land a solution. =)
As always, I so appreciate any suggestions. I attached a database with two modules that allow you to see the code working on a small set of records (modGo) and then failing on a large set of records (modNoGo).
Code:
"File sharing lock exceeded. Increase MaxLocksPerFile registry entry."
Code:
"You have exceed 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 or with the SetOption method."
As always, I so appreciate any suggestions. I attached a database with two modules that allow you to see the code working on a small set of records (modGo) and then failing on a large set of records (modNoGo).
Code:
Option Compare Database
Option Explicit
Public Function UpdateToMaster()
Dim updaterec As Boolean
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim Ctr As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT " & _
"PioCode, MdlYear, SRSER2, SRFMLY, SRDr, SRTRIM, SRTRAN, VMACCE, VMINT, VMEXT, SR, CM, fldupdated " & _
"FROM tblNoGo", dbOpenDynaset)
Set rs2 = db.OpenRecordset("SELECT " & _
"fldPIO, fldMdlYr, fldSeries, fldFamily, fldDr, fldTrim, fldTrans, fldAccGrp, fldIntClr, fldExtClr, fldSR, fldCM " & _
"FROM tblPioMaster", dbOpenDynaset)
rs.MoveFirst
rs2.MoveFirst
With rs2
Do Until .EOF
Do Until rs.EOF
If rs!fldupdated = 0 Then
updaterec = True
For Ctr = 0 To 11 'Update this when adding additional criteria (e.g. 0-11 = 12 fields from MasterTable)
If Not IsNull(.Fields(Ctr)) Then
If .Fields(Ctr) <> rs.Fields(Ctr) Then
updaterec = False
Exit For
End If
End If
Next Ctr
If updaterec = True Then
rs.Edit
rs!PioCode = IIf(IsNull(!fldPIO), Null, !fldPIO)
rs!MdlYear = IIf(IsNull(!fldMdlYr), Null, !fldMdlYr)
rs!SRSER2 = IIf(IsNull(!fldSeries), Null, !fldSeries)
rs!SRFMLY = IIf(IsNull(!fldFamily), Null, !fldFamily)
rs!SRDr = IIf(IsNull(!fldDr), Null, !fldDr)
rs!SRTRIM = IIf(IsNull(!fldTrim), Null, !fldTrim)
rs!SRTRAN = IIf(IsNull(!fldTrans), Null, !fldTrans)
rs!VMACCE = IIf(IsNull(!fldAccGrp), Null, !fldAccGrp)
rs!VMINT = IIf(IsNull(!fldIntClr), Null, !fldIntClr)
rs!VMEXT = IIf(IsNull(!fldExtClr), Null, !fldExtClr)
rs!SR = IIf(IsNull(!fldSR), Null, !fldSR)
rs!CM = IIf(IsNull(!fldCM), Null, !fldCM)
rs!fldupdated = -1
rs.Update
End If
End If
rs.MoveNext
Loop
.MoveNext
rs.MoveFirst
Loop
End With
rs.Close
rs2.Close
Set db = Nothing
Set rs = Nothing
Set rs2 = Nothing
MsgBox "Worked!"
End Function
Comment