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




Reply With Quote