I use the following function just before quiting the application to test for
a file saize and set the autocompact on close to true if the file is greater
than a certain size. This means I do not have to compact it everytime it
closes but only when a certain size has been exceeded. Call it just before
your application.qui t statement.
Public Function AutoCompactCurr entProject()
Dim fs, f, s, filespec
Dim strProjectPath As String, strProjectName As String
strProjectPath = Application.Cur rentProject.Pat h
strProjectName = Application.Cur rentProject.Nam e
filespec = strProjectPath & "\" & strProjectName
Set fs = CreateObject("S cripting.FileSy stemObject")
Set f = fs.GetFile(file spec)
s = CLng(f.Size / 1000000) 'convert size of app from bytes to Mb's
If s > 3 Then 'edit the 3 (Mb's) to the max size you want
to allow your app to grow.
Application.Set Option ("Auto Compact"), 1 'compact app
Else
Application.Set Option ("Auto Compact"), 0 'no don't compact app
End If
End Function
"PC Datasheet" <no****@nospam. spam> wrote in message
news:bc******** ***********@new sread1.news.pas .earthlink.net. ..
The better thing to do is to just use the Kill command to delete Cust.mdb
and then recreate Cust.mdb and its tables.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com
"KEVIN97810 " <ke********@aol .com> wrote in message
news:20******** *************** ****@mb-m05.aol.com... Hello to all,
Assume my mdb name is Cust.MDB. I want to compact & repair the same Cust.MDB when the user exit the program. Is there a way you
can do it in code behind the EXIT button. I am dumping data from SQL to temp
table and also delete from these tables in Cust.MDB. This would cause the MDB to
get big. So I just want some code to compact and repair as user Exit from
the access database.
thanks a bunch.