Button to Compact Database

  • Thread starter Thread starter Dwayne Conyers
  • Start date Start date
D

Dwayne Conyers

I have code to compact the database. I need to add lines to report the size
to the user before and after compacting. Would appreciate any tips on
capturing the file size to a variable.

Thanks.


<!-- CODE APPEARS BELOW //-->

Private Sub cmdCompact_Click()
On Error GoTo Err_cmdCompact_Click

sizenow = CurrentProject
MsgBox sizenow

Dim currpath As String

currpath = CurrentProject.Path
ourmdb = CurrentProject.FullName
ourmde = currpath + "\lessons_learned.mde"

Dim accApp As Access.Application
Set accApp = New Access.Application
accApp.SysCmd 603, ourmdb, ourmde
accApp.SysCmd 602, ourmdb, ourmdb
Set accApp = Nothing
MsgBox "The database has been successfully compacted.", vbInformation +
vbOKOnly, "Operation Complete"

Exit_cmdCompact_Click:
Exit Sub

Err_cmdCompact_Click:
fooBAR

End Sub
 
Assuming you have the full pathname of the db, then FileLen(pathname) will
return the length of the file as a Long.


--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Back
Top