Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function CompactBackEndTables(TableName As String) As Boolean
On Error GoTo Err_Compact
Dim BackEnd As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset(TableName, dbOpenDynaset)
rs.MoveLast
rs.MoveFirst
Do Until rs.EOF
With rs
'Backend full path
BackEnd = rs!BackendPath
'Compact the Back-End database to a temp file.
DBEngine.CompactDatabase BackEnd, BackEnd & "Temp.mdb"
'Delete the previous backup file if it exists.
If Dir(BackEnd & ".bak") <> "" Then
Kill BackEnd & ".bak"
End If
'Rename the current database as backup and rename the temp file to
'the original file name.
Name BackEnd As BackEnd & ".bak"
Name BackEnd & "Temp.mdb" As BackEnd
End With
rs.MoveNext
Loop
CompactBackEndTables = True
Exit_Compact:
Exit Function
Err_Compact:
MsgBox Err.Description
Resume Exit_Compact
End Function
BackEnd = CurrentProject.Path & "\YourDatabaseName.mdb"
or BackEnd = CurrentProject.Path & rs!BackendPath
[blue]DBEngine.CompactDatabase BackEnd, [purple][b]BackEnd & "Temp.mdb"[/b][/purple][/blue]