Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compact Dbase Error 1

Status
Not open for further replies.

trudye10

Programmer
Sep 8, 2006
67
Hey Guys I searched FAQ and found the following code, however, it will not compile. Error Message (Method or member not found and it highlights .CompactRepair .

I have included DAO 3.6, what am I missing?

Function RepairDatabase()

Dim strSource As String
Dim strDestination As String
Dim strBkupDestination As String
Dim OldName, NewName

' Trap for errors.
On Error GoTo error_handler

' Define file names and pathes.
OldName = "D:\AON\Batch\TestBatch.mdb": NewName = "D:\AON\Batch\TestBatch" & Date & ".mdb"
strSource = "D:\AON\Batch\TestBatch.mdb"
strDestination = "D:\AON\Batch\TestBatch.mdb"
strBkupDestination = "D:\AON\Lauri\Bkup_TestBatch_" & Date & ".mdb"

'Rename Current Dbase file.
Name OldName As NewName

'BkUp File Original Database Before Compacting
BkUp_Files:
FileCopy strSource, strBkupDestination

Compact:
RepairDatabase = _
Application.CompactRepair( _
LogFile:=True, _
SourceFile:=strSource, _
DestinationFile:=strDestination)

' Reset the error trap and exit the function.
On Error GoTo 0
Exit Function

' Return False if an error occurs.
error_handler:
RepairDatabase = False
MsgBox "Compact/ Repair Failed, Please Rerun"
End Function


 
Hi,

Do you have a reference set to "Microsoft Access 10.0 Object Library"?

I put the code into a brand new db with only refs to the above ref and to "Visual Basic for Applications" and it compiled ok

jimlad

"There's this thing called being so open-minded your brains drop out." - Richard Dawkins
 
Thank you so much for responding. I do not have any Microsoft Access Obj. Libs at all. Ths closest thing I have is Ms ActiveX Data Obj 2.6 Lib. I am running Access 2k.

Thanx,
Trudye
 
No Microsoft Access Obj. Libs at all? are you looking in the vba editor under Tools/References?

Maybe the link to the reference is broken? This may help?

jimlad

"There's this thing called being so open-minded your brains drop out." - Richard Dawkins
 
Yea, unfortunately I am looking in the References dialog box. Microsoft Access Obj. s/b the first entry listed with the prefix Microsoft *. My first entry is in the references dialog box with a Microsft prefix is: Microsoft Active Sever Pages Obj Lib.


THank so much for responding,
Trudye
 
Your posted VBA code is obviously Access VBA, isn't it ?
The reason I ask is that CompactRepair is a method of the Access.Application object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV, thanks for chiming in. Yes, I am trying to Compact/Repair an Access dbase using Access/vba.

Do you happen to know what reference it is I'm missing? I am using Access 2k.


Thanx,
Trudye
 
The CompactRepair method was introduced with acXP (aka ac2002).

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
So I out of luck? Compact on close would take too long, I wanted to schedule the compact. Any ideas?

Thanx,
Trudye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top