Cannot remove Access Error 3052 Increase MaxLocksPerFile registry

Hi all,

I have a db table with 640k records and after adding an autonumber field for a primary key, I got the "Access Error 3052 Increase MaxLocksPerFile registry" error.

So, after a bit of research, I found a few solutions including this one from Joe:

http://www.experts-exchange.com/Programming/Microsoft_Development/Q_27939343.html

After following the solution, I still kept getting the same error so I decided to write my own routine to loop through and number the records one-by-one to achieve the same result.

However, when running my routine, it just hangs and will not go any further than a few thousand records (hours later!).

I do not get any errors at all from the db and am hoping someone will be able to help me sort it out.

I have attached a sample db with my routine in it as well.

Any ideas?

Thanks,
Lai
sample.accdb
Laila JacksonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert ShermanOwnerCommented:
My first question is about your initial attempt to add an autonumber field as a primary key to your table.  Were you able to add the autonumber field and save the table or did the error prevent you from saving the table design (and thus prevented you from adding the autonumber field)?

If all you are want to do is add an Autonumber key field and are not able to do it by just changing the existing table's design, then have you considered or tried creating a new table with the exact same structure of the existing table PLUS the autonumber field, and then doing an append query from the old table to the new one, matching up all the table fields except, obviously, the autonumber which would get filled in during the append?

Looking at the code sample you provided:

Are the combination of OriginPortID and DestinationPortID unique for each record?  The way you are setting the RoutingID field would require that this pair be unique for each record, and if they aren't, then for each record in the Do/While loop you are setting multiple (possibly MANY) records with a RoutingID of whatever number you have incremented iCode up to..    This would certainly explain why the code ends up hanging...  

I'm not sure, but I would think that if you are looping over the recordset anyway, you could just edit and update directly on that recordset, eliminating the need for the 2nd connection and executing a SQL statement for each pass through the loop, something like below.   Keep in mind that even if this is successful, you would have a numeric index but you still won't have the full benefit of an Autonumber key, since new records will not get numbered... (Note that I haven't tested this since I don't have the data, so please only run this on a COPY of your file first. )

Sub update_codes()
    

    
    'addressing Access Error 3052 Increase MaxLocksPerFile registry ->
    DAO.DBEngine.SetOption dbMaxLocksPerFile, 50000
  
    
    Dim db As Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("routes")
    
    'setting code variable ->>
    iCode = 1
    
    'retrieving parameters ->>
    If rs.RecordCount > 0 Then
        rs.MoveFirst
        
        'looping through the recordset and setting the Route Code ->>
        Do While Not rs.EOF
            rs.Edit
            
            rs("RoutingID") = iCode
            rs.Update
            
            rs.MoveNext
            iCode = iCode + 1
        Loop
    End If
    
    'cleaning up ->>
    Set rs = Nothing

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Laila JacksonAuthor Commented:
Hi thanks for responding.

Were you able to add the autonumber field and save the table or did the error prevent you from saving the table design

Unfortunately not. I got the error and access (2013) would not allow me to save the table design.

have you considered or tried creating a new table with the exact same structure of the existing table PLUS the autonumber field, and then doing an append query from the old table to the new one, matching up all the table fields except, obviously, the autonumber which would get filled in during the append?

In my own troubleshooting of this issue, I got the error and then ran through the  DAO.DBEngine.SetOption dbMaxLocksPerFile, 20000 solution to see if it would resolve the issue and it did not.

After that, I remade the table from scratch thinking it might have somehow got itself in a twist but it did not make any difference. I then tried a compact and repair which was also suggested online as well and that did not work either.

Finally, I used my original data and tried both a maketable and append query with the autonumber added and it gave an out of memory error which is common for this amount of records.

Are the combination of OriginPortID and DestinationPortID unique for each record?

Yes. I specifically checked this in my own troubleshooting.

I ran the solution you provided on the sample dataset and it appeared to work without any issues which is a great result.

I will give it a try against the larger table and revert back.

Thanks heaps Robert.

Lai
0
Laila JacksonAuthor Commented:
@ Rob,

That solution you provided worked a treat across 640467 records in just under 23 seconds!

Thanks a million I will used your method in future as well for these types of scenarios.. Much much faster than using ADO and two connections.

Lai
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.