Hi all,
Latest challenge ... when a new project is launched, the code below is executed, and fails because the found set has 15,000 records. I followed the directions here:
http://support.microsoft.com/default.aspx?id=815281
for using the immediate window and the SetOption method to temporarily change the MaxLocksPerFile value, but I received an error. Is there any instruction that I could add to my code just before the large update to modify this setting? I'm unnerved by the warnings for editing the registry key! Thanks for any advice. Here is the code:
' now update tblSegment with the correct segment number for each contact
intSegmentNum = Me!proj_segments ' initial value = max segment number
theLoopCount = lngRemainder / intSegmentNum ' calculate number of contacts per segment
' VBA will round up - handled by last loop execution
intSegSize = theLoopCount ' save copy of segment size
strSQL = "SELECT * FROM tblSegment " & _
"WHERE (((tblSegment.seg_projectID)='" & strProjectID & "'));"
Set myRS = myDB.OpenRecordset(strSQL)
myRS.MoveFirst
Do While intSegmentNum > 0 ' do for each segment
Do While theLoopCount > 0 ' do for each contact within this segment
myRS.Edit
myRS!seg_num = intSegmentNum
myRS.Update
theLoopCount = theLoopCount - 1
myRS.MoveNext
Loop
lngRemainder = lngRemainder - intSegSize ' contacts remaining after each segment loop
intSegmentNum = intSegmentNum - 1 ' decrement segment number for next loop
If intSegmentNum = 1 Then ' if next loop is last segment
theLoopCount = lngRemainder ' use remainder
Else
theLoopCount = intSegSize ' initialize loop counter for next segment
End If
Loop
myRS.Close
Latest challenge ... when a new project is launched, the code below is executed, and fails because the found set has 15,000 records. I followed the directions here:
http://support.microsoft.com/default.aspx?id=815281
for using the immediate window and the SetOption method to temporarily change the MaxLocksPerFile value, but I received an error. Is there any instruction that I could add to my code just before the large update to modify this setting? I'm unnerved by the warnings for editing the registry key! Thanks for any advice. Here is the code:
' now update tblSegment with the correct segment number for each contact
intSegmentNum = Me!proj_segments ' initial value = max segment number
theLoopCount = lngRemainder / intSegmentNum ' calculate number of contacts per segment
' VBA will round up - handled by last loop execution
intSegSize = theLoopCount ' save copy of segment size
strSQL = "SELECT * FROM tblSegment " & _
"WHERE (((tblSegment.seg_projectID)='" & strProjectID & "'));"
Set myRS = myDB.OpenRecordset(strSQL)
myRS.MoveFirst
Do While intSegmentNum > 0 ' do for each segment
Do While theLoopCount > 0 ' do for each contact within this segment
myRS.Edit
myRS!seg_num = intSegmentNum
myRS.Update
theLoopCount = theLoopCount - 1
myRS.MoveNext
Loop
lngRemainder = lngRemainder - intSegSize ' contacts remaining after each segment loop
intSegmentNum = intSegmentNum - 1 ' decrement segment number for next loop
If intSegmentNum = 1 Then ' if next loop is last segment
theLoopCount = lngRemainder ' use remainder
Else
theLoopCount = intSegSize ' initialize loop counter for next segment
End If
Loop
myRS.Close