|
-
Nov 21st, 2000, 05:19 PM
#1
Thread Starter
Lively Member
Compact & repair Access 2000 database
Hi,
I know that we can compact and repair database with Tools>database utilities>compact& repair database option,but can anyone tell me as is it possible to do this with the code.Iam using Access2000
Any help will be highly appreciated.
Regards
-
Nov 21st, 2000, 05:31 PM
#2
Fanatic Member
...
try this...
Private Sub Command1_Click()
' this line will compact the "c:\myDir\db1.mdb" database to "c:\myDir\db2.mdb".
' after this line had been called you will have the original
' uncompacted database in "c:\myDir\db1.mdb"
' and the new compacted database in "c:\myDir\db2.mdb".
DBEngine.CompactDatabase "c:\myDir\db1.mdb", "c:\myDir\db2.mdb"
End Sub
and let us know
-
Nov 22nd, 2000, 08:30 AM
#3
Black Cat
I tried writing code once using Access VBA to issue the Compact and Repair command after a function that deleted records from a table, and I got an error message telling me the c&r command cannot be executed via code...
Josh
-
Nov 22nd, 2000, 10:03 AM
#4
Fanatic Member
Perfectly possible but remember that Compact and Repair operations need exclusive access to the database so have to be done from a separate piece of code. Running it from VB via automation would be fine.
Lafor's code would work but it could not be run from c:\myDir\db1.mdb itself.
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 22nd, 2000, 02:41 PM
#5
Black Cat
Yeah, I was using this in Access VBA. It is from Access.Application.
Code:
RunCommand acCmdCompactDatabase
So in other words, you can compact a DB from Access VBA, only VB.
Josh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|