PC Review


Reply
Thread Tools Rate Thread

Database Compacting Function

 
 
TESA0_4
Guest
Posts: n/a
 
      23rd Sep 2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compacting Database =?Utf-8?B?R2lsbHo=?= Microsoft Access 4 13th Apr 2007 08:30 PM
Compacting Database =?Utf-8?B?dGFzdHllcnM=?= Microsoft Access Form Coding 1 8th May 2006 05:10 AM
Compacting a database =?Utf-8?B?Q2Fyb2xN?= Microsoft Access Getting Started 1 9th Aug 2005 07:09 PM
Compacting a database Rajesh Candamourty Microsoft Access Form Coding 4 7th Jun 2005 01:13 AM
Compacting a database Rajesh Candamourty Microsoft Access Reports 4 7th Jun 2005 01:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:33 AM.