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
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