the database isn't 'launched' as such .... it's totally seperate. i just need to shut it down while this code is run and then have it started up again. it's like the kind of thing that MySQL does on webservers to keep database sizes down.
this code should give you the idea of what i'm doing
Public Declare Function GetTempPath Lib "kernel32" Alias _
"GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer _
As String) As Long
Public Const MAX_PATH = 260
Public Sub CompactJetDatabase(Location As String)
Dim MasterFile As String
Dim strBackupFile As String
Dim strTempFile As String
' need to shut down db here
MasterFile = Location & "\fms.mdb"
'Check the database exists
If Dir$(MasterFile) = "fms.mdb" Then
' Create temporary filename
strTempFile = Location & "\" & "fms_temp.mdb"
If Dir$(strTempFile) Then Kill strTempFile
' Do the compacting via DBEngine
DBEngine.CompactDatabase strTempFile, OptimDb
' add in code to copy OptinDB back to original here
MsgBox ("Database is optimised! at last!")
'need to restart db here
Else
MsgBox ("blah blah error! we're all going to die!")
End If
End Sub
Enter your message below
Sign in or Join us (it's free).