Shelnutt
asked on
VBA; Access: compact and repair split db
I have a split db in Access (application mdb front and data in a separate mdb file). When user exits the application, I want to "compact and repair" the mdb file housing the data tables. How can I do that?
mx: When you are 'linked' to tables in a backend mdb, you do not actually have the mdb 'opened' do you? Are you saying that utility will compact and repair under that condition?
With a reference to DAO, you can use:
DBEngine.CompactDatabase strExistingFilename, strNewFilename
Otherwise, you can add a reference to Jet Replication Objects and use:
How To Compact Microsoft Access Database Through ADO
http://support.microsoft.com/kb/230501
DBEngine.CompactDatabase strExistingFilename, strNewFilename
Otherwise, you can add a reference to Jet Replication Objects and use:
How To Compact Microsoft Access Database Through ADO
http://support.microsoft.com/kb/230501
gRay ... I didn't say anything ... but I suggest everyone read the info on Michael's site ... regarding the subject ... and the various pros and cons of the methods.
mx
mx
ASKER
After reading several posts, I was able to figure out how to solve my problem. Here is the code I used:
Dim fs As FileSystemObject
Set fs = CreateObject("Scripting.Fi leSystemOb ject")
Dim SourceFile As String
Dim DestinationFile As String
Dim NewFile As String
Hourglass True
SourceFile = "c:\program files\superaudits\superaud its_bes.md b"
DestinationFile = "c:\superaudits_bes_mdb"
NewFile = "c:\superaudits_besnew.mdb "
fs.CopyFile SourceFile, DestinationFile, True
DBEngine.CompactDatabase DestinationFile, NewFile
fs.CopyFile NewFile, SourceFile, True
fs.DeleteFile DestinationFile
fs.DeleteFile NewFile
None of the posts really resolved the issue. The closest answer to what I needed was from PaulHews.
Thank you all very much for your time!
Dim fs As FileSystemObject
Set fs = CreateObject("Scripting.Fi
Dim SourceFile As String
Dim DestinationFile As String
Dim NewFile As String
Hourglass True
SourceFile = "c:\program files\superaudits\superaud
DestinationFile = "c:\superaudits_bes_mdb"
NewFile = "c:\superaudits_besnew.mdb
fs.CopyFile SourceFile, DestinationFile, True
DBEngine.CompactDatabase DestinationFile, NewFile
fs.CopyFile NewFile, SourceFile, True
fs.DeleteFile DestinationFile
fs.DeleteFile NewFile
None of the posts really resolved the issue. The closest answer to what I needed was from PaulHews.
Thank you all very much for your time!
Thank you for posting your solution ... we appreciate that.
mx
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://trigeminal.com/lang/1033/utility.asp?ItemID=2#2