T
TESA0_4
Hi,
Microsoft VBA help provides the following code suggestion for initiating the
compacting of a database.
Function RepairDatabase(strSource As String, _
strDestination As String) As Boolean
' Input values: the paths and file names of
' the source and destination files.
' Trap for errors.
On Error GoTo error_handler
' Compact and repair the database. Use the return value of
' the CompactRepair method to determine if the file was
' successfully compacted.
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
End Function
I have created a button on a form on my Front End that is accessible to
users with System Admin rights to initiate the function which I have pointed
at the Back End of the application. It seems to work fine except I don't know
how to intentionally cause a failure of the compaction so that I test the
'failed' side of the function!
I want to test it because the Help notes say that the filepath and name of
the log file has to be passed to the Function. Does this mean that I need to
create an 'empty' file at my filepath with a name like 'CompactLog.txt', or
does the VB code automatically generate a file with my nominated file name
and extension (like .txt). Also, am I right to guess that an appropriate file
type for the log is .txt?
Thanks in anticipation for any help you can offer.
Tesa
Microsoft VBA help provides the following code suggestion for initiating the
compacting of a database.
Function RepairDatabase(strSource As String, _
strDestination As String) As Boolean
' Input values: the paths and file names of
' the source and destination files.
' Trap for errors.
On Error GoTo error_handler
' Compact and repair the database. Use the return value of
' the CompactRepair method to determine if the file was
' successfully compacted.
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
End Function
I have created a button on a form on my Front End that is accessible to
users with System Admin rights to initiate the function which I have pointed
at the Back End of the application. It seems to work fine except I don't know
how to intentionally cause a failure of the compaction so that I test the
'failed' side of the function!
I want to test it because the Help notes say that the filepath and name of
the log file has to be passed to the Function. Does this mean that I need to
create an 'empty' file at my filepath with a name like 'CompactLog.txt', or
does the VB code automatically generate a file with my nominated file name
and extension (like .txt). Also, am I right to guess that an appropriate file
type for the log is .txt?
Thanks in anticipation for any help you can offer.
Tesa