How to compress a database automatically just bevore exiting ?

S

Simeon

Hi folks,

I am trying to solve a problem with the compressing of an Access 2003
database just before I close it. For now I wrote this sub procedure, which
enables the automatic compressing if a file has reached a certain filesize:

Public Sub dbcompress(filesize As Long)

If FileLen(CurrentDb.Name) > filesize * 1024 * 1024 Then
Application.SetOption ("Auto Compact"), 1
Else
Application.SetOption ("Auto Compact"), 0
End If

Exit_dbcompress:
Exit Sub

Err_dbcompress:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_dbcompress

End Sub

The problem is an error message I get before Access is closed. After closing
the current database the compress process is started and the after a while
this error message appears bevor the compress process has ended:

"You can't close MS Office Access right now. If you are executing a VB
module which uses DDE or OLE you have to cancel it first"

I would be thankful for an advice how to remove the error message.

Simeon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top