Exodus
Registered User.
- Local time
- Today, 06:40
- Joined
- Dec 4, 2003
- Messages
- 317
Ok so I'm trying to get the backend that resides on the network to compact when the last user exits the FE. I have read that network compacts can corrupt the db becuase of the data compacting over the network. I have ran across Rogers compact be code was wondering if there is the same risk with doing it this way.
Code:
'**********************************
'Created by Roger Carlson *
'Roger.Carlson@spectrum-health.org*
'Rog3erc@aol.com *
'**********************************Private Sub cmdCompact_Click()
'On Error GoTo Err_cmdCompact_Click
Dim LinkPathFile As String
Dim LinkPath As String
Dim LinkFile As String
Dim FileWithoutExtention As String
Dim Pw As String
Dim GetPwLength As String
Dim Pwis As String
'uses the findsource, getpath, and getfile functions
'to determine the path and filename of the linked database
LinkPathFile = Mid(FindSource(), InStr(FindSource(), "\\"))
Pw = Mid(FindSource(), InStr(FindSource(), ";"))
GetPwLength = InStr(2, Pw, ";")
Pwis = Mid(Pw, 1, GetPwLength)
LinkPath = getpath(LinkPathFile)
LinkFile = getfile(LinkPathFile)
FileWithoutExtention = Left(LinkFile, InStr(LinkFile, ".") - 1)
Debug.Print Pw
'Debug.Print FindSource()
Debug.Print GetPwLength
Debug.Print Pwis
'Compact the Back-End database to a temp file.
DBEngine.CompactDatabase LinkPath & LinkFile, LinkPath & FileWithoutExtention & "Temp.mdb", Pwis, , Pwis
'Delete the previous backup file if it exists.
If Dir(LinkPath & FileWithoutExtention & ".bak") <> "" Then
Kill LinkPath & FileWithoutExtention & ".bak"
End If
'Rename the current database as backup and rename the temp file to
'the original file name.
Name LinkPath & LinkFile As LinkPath & FileWithoutExtention & ".bak"
Name LinkPath & FileWithoutExtention & "Temp.mdb" As LinkPath & LinkFile
Exit_cmdCompact_Click:
Exit Sub
Err_cmdCompact_Click:
MsgBox Err.Description
Resume Exit_cmdCompact_Click
End Sub