Autonumber

L

Les

Delete all your records, then compact database.
Autonumbering should start at 1 again.
 
N

natasha

How can I compact db programaticallY?
I am running code in the db:delete records in the table
and return autonumber to 1.Can I compact db
programatically in my current open db?

thanks
 
R

Ron Hinds

natasha said:
How can I compact db programaticallY?
I am running code in the db:delete records in the table
and return autonumber to 1.Can I compact db
programatically in my current open db?

thanks

I don't believe it's possible to compact the currently open db
programatically. Unless you have a split db and the BE is what you want to
compact. Then you would use code like the following:

'First rename the original, can't compact to same name
'strDB is the db to compact's name
'Strip off ".mdb"
strDBBackup = Left(strDB, Len(strDB) - 4)
'Add "Backup.mdb" to name
strDBBackup = strDBBackup & "Backup.mdb"
'Rename DB to Backup name
Name strDB As strDBBackup
DBEngine.CompactDatabase strDBBackup, strDB
'Assuming you've implemented an error handler, and all has gone well, delete
the original
'If there is an error then this line won't be executed and you'll still have
the backup
Kill strDBBackup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top