Results 1 to 2 of 2

Thread: Compacting a database

  1. #1

    Thread Starter
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Possibly on the first line, DB.CLOSE, but that assumes that you have the database open before calling this sub.

    Also, if there are multiple users of this database, you cannot get exclusive access to the file and will not be able to compact it unless everyone else who is using the database has also closed their reference to it

  2. #2
    New Member
    Join Date
    Jan 2000
    Location
    Calgary
    Posts
    6

    Post

    Question. When we use a procedure for compacting a database, is there any untrappable error that could occur during this call:
    DBEngine.CompactDatabase sDBName, sBackup

    which would then allow
    Kill sDBName
    to occur thus removing the database from the system?

    The entire procedure is below:

    Sub CompactDatabase(sDBName As String, sBackup As String)
    on error goto errtrap
    db.Close

    'Check to see if the tempory backup exists
    If Len(Dir$(sBackup)) > 0 Then 'Backup exists

    Kill sBackup 'Delete it

    End If

    'Compact the database to the tempory one
    DBEngine.CompactDatabase sDBName, sBackup

    'Delete the current one
    Kill sDBName

    'Compact the backup to the actual database
    DBEngine.CompactDatabase sBackup, sDBName

    'And remove the backup database
    Kill sBackup

    OpenDB (App.Path & "\demo.mdb")
    exit sub
    errtrap:
    msgbox "there is an error"
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width