S
StuJol
im currently using the following code to compact and repair my BE database on
close of my FE.
Public Sub cmdCompact_Click()
On Error GoTo Err_cmdCompact_Click
'Compact the Back-End database to a temp file.
DBEngine.CompactDatabase "C:\Program Files\Job Manager\Database\Job
Manager Database.mdb", "C:\Program Files\Job Manager\Database\Job Manager
Database Temp.mdb"
'Delete the previous backup file if it exists.
If Dir("C:\Program Files\Job Manager\Database\Job Manager Database.bak")
<> "" Then
Kill "C:\Program Files\Job Manager\Database\Job Manager Database.bak"
End If
'Rename the current database as backup and rename the temp file to the
original file name.
Name "C:\Program Files\Job Manager\Database\Job Manager Database.mdb" As
"C:\Program Files\Job Manager\Database\Job Manager Database.bak"
Name "C:\Program Files\Job Manager\Database\Job Manager Database
Temp.mdb" As "C:\Program Files\Job Manager\Database\Job Manager Database.mdb"
'Copy the backup database to the backup directory.
Name "C:\Program Files\Job Manager\Database\Job Manager Database.bak" As
"C:\Program Files\Job Manager\Database\backup\Job Manager Database " &
Format(Date, "dddd, mmm d yyyy") & ".bak"
Exit_cmdCompact_Click:
Exit Sub
Err_cmdCompact_Click:
MsgBox Err.Description & " " & Err.Number
Resume Exit_cmdCompact_Click
End Sub
this code creattes a database.bak file which im trying to copy to a new
directory but are unable to. I've used the file copy method but just keep
getting errors and i've used the rename method to try and save file in a
different directory but that doesnt work either.
Any ideas please?
close of my FE.
Public Sub cmdCompact_Click()
On Error GoTo Err_cmdCompact_Click
'Compact the Back-End database to a temp file.
DBEngine.CompactDatabase "C:\Program Files\Job Manager\Database\Job
Manager Database.mdb", "C:\Program Files\Job Manager\Database\Job Manager
Database Temp.mdb"
'Delete the previous backup file if it exists.
If Dir("C:\Program Files\Job Manager\Database\Job Manager Database.bak")
<> "" Then
Kill "C:\Program Files\Job Manager\Database\Job Manager Database.bak"
End If
'Rename the current database as backup and rename the temp file to the
original file name.
Name "C:\Program Files\Job Manager\Database\Job Manager Database.mdb" As
"C:\Program Files\Job Manager\Database\Job Manager Database.bak"
Name "C:\Program Files\Job Manager\Database\Job Manager Database
Temp.mdb" As "C:\Program Files\Job Manager\Database\Job Manager Database.mdb"
'Copy the backup database to the backup directory.
Name "C:\Program Files\Job Manager\Database\Job Manager Database.bak" As
"C:\Program Files\Job Manager\Database\backup\Job Manager Database " &
Format(Date, "dddd, mmm d yyyy") & ".bak"
Exit_cmdCompact_Click:
Exit Sub
Err_cmdCompact_Click:
MsgBox Err.Description & " " & Err.Number
Resume Exit_cmdCompact_Click
End Sub
this code creattes a database.bak file which im trying to copy to a new
directory but are unable to. I've used the file copy method but just keep
getting errors and i've used the rename method to try and save file in a
different directory but that doesnt work either.
Any ideas please?