Compact and Repair Questions

Honestly, it doesn't matter HOW you get the path as long as you get the path. Mine just involves a few shortcuts instead of the whole DBEngine(0).Workspaces(0).Databases(0) thing - CurrentDb is the same thing.

The only thing to be careful of is that the connect string tends to start with "Database=".
 
Used yours and it seems to be working.

It appears that if you do a 2nd back up the code does not overwrite the first - the date modified on my finder doesn't change. I have not change anything in the backend before redoing the compact code, but even still it should replace the back up file shouldn't it? I am sure I had this working correctly when I was using it before.
 
Have you refreshed your folder? (Just hit F5 when the folder has the focus.) The date shouldn't change, but the time certainly should - the program automatically replaces the backup file once the compact and repair is completed. Basically it makes sure the compact can be done, then compacts the database into a temp file, then kills any existing backup file, then renames the existing database into the backup file, then renames the temp file into the main database.
 
That's what I thought - I am sure it is an issue of the display of the folder - not the backup, because I know it worked before.

Again - thank you for all of your help!
 
Not a problem.

You can always verify, btw, by putting a break point at the start of the procedure, and stepping through it to make sure everything is doing what it's supposed to.
 
Frothingslosh - Thank you again for this module and code - it has solved problems for me in 2 circumstances.

My brother who is helping me on my project made the suggestion that you might amend the code in the CompactSelectedDB module so that if the compact and repair fails the user is advised - otherwise it appears there is no way that they would know that. Of course Case 3 needs to be added to the button code.

If Application.CompactRepair(FilePath, TempFilePath, True) Then

'If BackupPath exists, delete it.
If FileExists(BackupPath) Then Kill BackupPath

'Rename the original file to the name in BackupPath.
Name FilePath As BackupPath

'Rename TempFilePath to FilePath.
Name TempFilePath As FilePath

'Return the 'success' code (255)
CompactSelectedDB = 255
Else
CompactSelectedDB = 3
End If
 
Edit: Yeah, you're right, that might not be a bad idea - I'd forgotten that CompactRepair actually returned a value.
 

Users who are viewing this thread

Back
Top Bottom