Giles,
try using this code from Jochem? I have not tries it myself as i havent used
Access in years, but its worth a pop...
just pop this baby into a Custom Tag...and Bob's your uncle, fannies your
Aunt.
<!-----------------------------------------------------------------\
Utility: CF_AccessCompact
Author: [EMAIL PROTECTED] (jochemd<AT>oli.tudelft.nl)
Revised By: Dain Anderson
Date: October 31, 2000
------------------------------------------------------------------
Use anyway you want, but keep the above header in place.
------------------------------------------------------------------
Description:
This utility accepts an Access database name as a parameter and
then compacts and repairs it remotely.
------------------------------------------------------------------
Usage:
<CFMODULE TEMPLATE="[path]/accesscompact.cfm" [attribute1=""] ...>
OR
<CF_AccessCompact [attribute1=""] ...>
------------------------------------------------------------------
Required Parameters:
DATABASE = Database name (same directory as this file)
-- No default. Required.
Optional Parameters:
Backup = Yes or No, whether to backup the database
--Default is "Yes".
BackupFile = The name to give the backup file if backup was
selected.
--Default will be today's date, followed by an
underscore character:
i.e., 10312000_MyData.mdb
PATH = Full-qualified path to the .mdb file.
--Default is ExpandPath('.')
------------------------------------------------------------------
Returns:
No return values.
\------------------------------------------------------------------>
<!--- Required Parameters --->
<CFPARAM NAME="Attributes.Database" DEFAULT="">
<!--- Optional Parameters --->
<CFPARAM NAME="Attributes.Backup" DEFAULT="Yes">
<CFPARAM NAME="Attributes.BackupFile" DEFAULT="#DateFormat(NOW(),
"MMDDYYYY")#_#Attributes.Database#">
<CFPARAM NAME="Attributes.Path" DEFAULT="#ExpandPath('.')#">
<!--- Other Parameters used internally --->
<CFPARAM NAME="Attributes.TempFile" DEFAULT="TEMP_#Attributes.Database#">
<CFPARAM NAME="Pipe" DEFAULT="\">
<!--- Check for the trailing pipe --->
<CFIF Right(Attributes.Path, 1) EQ "\">
<CFSET Pipe = "">
</CFIF>
<!--- No database specified --->
<CFIF NOT LEN(Attributes.Database)>
No database was specified.
<CFABORT>
</CFIF>
<!--- Create a backup database if backup was specified --->
<CFIF YesNoFormat(Attributes.Backup) IS "Yes">
<CFFILE ACTION="COPY"
SOURCE="#Attributes.Path##Pipe##Attributes.Database#"
DESTINATION="#Attributes.Path##Pipe##Attributes.BackupFile#">
</CFIF>
<!--- Connect to/Create the object --->
<CFTRY>
<CFOBJECT TYPE="COM" ACTION="CONNECT" NAME="objAccess"
CLASS="Access.Application">
<CFCATCH TYPE="Any">
<CFOBJECT TYPE="COM" ACTION="CREATE" NAME="objAccess"
CLASS="Access.Application">
</CFCATCH>
</CFTRY>
<!--- Compact the database to a temporary database --->
<CFSCRIPT>
/* Initialize the Access database engine */
objDBEngine = objAccess.DBEngine;
/* Compact the database to a temp file, keeping the original intact
until the tag completes */
objDBEngine.CompactDatabase("#Attributes.Path##Pipe##Attributes.Database#",
"#Attributes.Path##Pipe##Attributes.TempFile#");
</CFSCRIPT>
<!--- Delete the old database and rename the temporary database --->
<CFIF FileExists("#Attributes.Path##Pipe##Attributes.TempFile#")>
<CFFILE ACTION="DELETE"
FILE="#Attributes.Path##Pipe##Attributes.Database#">
<CFFILE ACTION="RENAME"
SOURCE="#Attributes.Path##Pipe##Attributes.TempFile#"
DESTINATION="#Attributes.Path##Pipe##Attributes.Database#">
</CFIF>
--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]