Quote:
Originally Posted by nico5038
Create a DDL query that will add the autonumber like:
-
alter table tblA add column IDX counter
-
tblA needs to be replaced with your table name and IDX with the fieldname you want to use for the counter.
This is the fastest solution. To reset an autonumber after a "Delete * from tblA" you just need a compact and repair of the database, but that's slower.
Nic;o)
This solution results in the error: File sharing lock count exceeded. Increase MaxLocksPerFile registry entry.
I then found a microsoft resolution that indicated the following would change this setting: In Immediate Window, enter the following codeDAO.DBEngine.SetOption dbmaxlocksperfile
,15000
6. Press the ENTER key to run the line of code.
I ran this multiple times up to 1,000,000 and it made no difference. I didn't feel eager enough to change my registry setting.
I did try to add a compact database command in a macro (which does reset the counter after I removed the records in the table) but Access does not allow the compacting of a database to be initiated from a macro.
The solution I went with was declaring the table from a sql statement that identified the index field. This gets me my counter index but adds a 2nd location that must be updated if the source file format changes.
I'd still like to perform this using sql in access.
hjohnson