Results 1 to 9 of 9

Thread: [RESOLVED] Access database compact/repair

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    Resolved [RESOLVED] Access database compact/repair

    This should be a simple problem to answer. I wish to carry out a compact and repair process on several Access databases being used in a program.

    From the Forum FAQs I obtained the following straightforward code, from a tutorial written by RobDog888.

    However when I try to get it to run, I receive an error message that the method is not found. The highlighted error is the oApp.CompactRepair instruction at the start of that code line.

    I have called up reference to Microsoft Access 9.0 Object Library.

    Any suggestions would be appreciated please.

    camoore

    Wales, UK

    Code:
    'Add a reference to MS Access xx.0 Object Library
    Private Sub Command1_Click()
    
        On Error GoTo MyError
    
        Dim oApp As Access.Application
    
        Set oApp = New Access.Application
        oApp.CompactRepair "C:\RobDog888.mdb", "C:\RobDog888CRd.mdb", False
        Kill "C:\RobDog888.mdb"
        Name "C:\RobDog888CRd.mdb" As "C:\RobDog888.mdb"
        MsgBox "Compact & Repair Complete!", vbOKOnly
        oApp.Quit acQuitSaveNone
        Set oApp = Nothing
        Exit Sub
    
    MyError:
        MsgBox Err.Number & " - " & Err.Description, vbOKOnly
    End Sub
    Last edited by si_the_geek; Oct 4th, 2011 at 11:02 AM. Reason: fixed code tags

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