Compact an MDE file through DAO
Hi everyone,
I've figured out the best way for me to compact my database from the posts here but I have a small problem with it. My backend end is an MDE file (have no idea why I did that now) and the code I have doesn't seem to work with MDE files.
Is it possible to compact an mde file through DAO?? I'd rather not change the BE to an mdb file now because I would need to import everything into a new DB and then secure it again.
Thanks,
Rcurtin.
Hi everyone,
I've figured out the best way for me to compact my database from the posts here but I have a small problem with it. My backend end is an MDE file (have no idea why I did that now) and the code I have doesn't seem to work with MDE files.
Code:
Dim RS As DAO.Recordset, DB As DAO.Database
Dim NewDBName As String, DBName As String
Set DB = CurrentDb()
Set RS = DB.OpenRecordset("DBNames")
On Error Resume Next
RS.MoveFirst
Do Until RS.EOF
DBName = RS("DBFolder") & "\" & RS("DBName")
Debug.Print "original: " & DBName
' Create a new name for the compacted database.
' This example uses the old name plus the current date.
NewDBName = Left(DBName, Len(DBName) - 4)
NewDBName = NewDBName & " " & Format(Date, "MMDDYY") & ".mdb"
Debug.Print "newname: " & NewDBName
DBEngine.CompactDatabase DBName, NewDBName
RS.MoveNext
Loop
' Close the form, and then close Microsoft Access
DoCmd.Close acForm, "CompactDB", acSaveYes
RS.Close
' DoCmd.Quit acSaveYes
Is it possible to compact an mde file through DAO?? I'd rather not change the BE to an mdb file now because I would need to import everything into a new DB and then secure it again.
Thanks,
Rcurtin.
Last edited: