I'm working on a utility to archive data from my application. The utility creates two copies of the db in an "archive" directory.
I want to compact the first one and save it with all the records as a backup to the operation.
I want to run two action queries in the second one to switch the selected set and then to delete them, and then compact that one as the archive of the records I'm about to delete in the original file.
(I tried 'OpenCurrentDatabase' but ran into problems when I tried to compact it - an error message about not being able to do that to the current db.)
My code is almost working except that the db's are left open after I run the lines that open them and do the things I want them to do. I'm running blind here, having adapted code from snippets I found here on the forum and from Roger Carlson's site (the BackUpWithCompact.mdb). I just don't know how to code them to close once they do their thing.
Could someone point me in the right direction for this?
Here's the code for running these processes:
Sorry Folks. Sometimes I post my questions way too quickly. All I had to do was put a "Quit" line in the macros to switch the selected set and delete the selected set. It works really nicely now, except for the potential lag between the VB code and the Shell activity. I think I'll try to set up some kind of Do Until loop that checks for the PID (htask value?) and doesn't find it before trying to rename the temporary db's to their permanent names. Actually, it would just be easier to give them their final names right up front, wouldn't it. <<sigh>> Such a flake sometimes. Thanks everybody. -Dudley
I want to compact the first one and save it with all the records as a backup to the operation.
I want to run two action queries in the second one to switch the selected set and then to delete them, and then compact that one as the archive of the records I'm about to delete in the original file.
(I tried 'OpenCurrentDatabase' but ran into problems when I tried to compact it - an error message about not being able to do that to the current db.)
My code is almost working except that the db's are left open after I run the lines that open them and do the things I want them to do. I'm running blind here, having adapted code from snippets I found here on the forum and from Roger Carlson's site (the BackUpWithCompact.mdb). I just don't know how to code them to close once they do their thing.
Could someone point me in the right direction for this?
Here's the code for running these processes:
Code:
AppPath = SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"
htask = Shell(AppPath & " """ & strDestinationDir & "TempDB_BU.mdb" & """" & " /compact", 1) 'compacts backup file
If htask <> 0 Then 'continue
If Not Dir(strDestinationDir & "TempDB_BU.mdb") = "" Then FileCopy (strDestinationDir & "TempDB_BU.mdb"), DBBackupFileName
MsgBox "Backup File Successfully Created: " & strDestinationDir & DBBackupFileName
'Process the Archive file - Switch the selected set, delete selecteds, compact
htask = Shell(AppPath & " """ & strDestinationDir & "TempDB_Arch.mdb" & """" & " /x macARCHIVE_SwitchSelected")
If htask <> 0 Then
htask = Shell(AppPath & " """ & strDestinationDir & "TempDB_Arch.mdb" & """" & " /x macARCHIVE_DeleteSelected")
If htask <> 0 Then
htask = Shell(AppPath & " """ & strDestinationDir & "TempDB_Arch.mdb" & """" & " /compact", 1)
If htask <> 0 Then FileCopy strDestinationDir & "TempDB_Arch.mdb", DBArchiveFileName
Else
GoTo Fail
End If
Else
GoTo Fail
End If
Else
Fail: MsgBox "Archive Process Failed."
Exit Sub
End If
Sorry Folks. Sometimes I post my questions way too quickly. All I had to do was put a "Quit" line in the macros to switch the selected set and delete the selected set. It works really nicely now, except for the potential lag between the VB code and the Shell activity. I think I'll try to set up some kind of Do Until loop that checks for the PID (htask value?) and doesn't find it before trying to rename the temporary db's to their permanent names. Actually, it would just be easier to give them their final names right up front, wouldn't it. <<sigh>> Such a flake sometimes. Thanks everybody. -Dudley
Last edited: