Thanks for your reply Dale. My comments are inline.
Dale Fye said:
I strongly endorse Jack's comments about:
1. FE on users PC's
Users are NOT on any kind of a network. Each user is completely independent
of any other user. One has nothing to do with the other.
2. Don't try to backup if someone is connected to the backend.
Does not apply to my situation.
What code
are you using for the backend backup?
Here is the code:
Function CompactBackendData()
On Error GoTo CompactData_ERR
Dim LinkPathFile As String
Dim LinkPath As String
Dim LinkFile As String
Dim FileWithoutExtention As String
Dim strFolder As String
Dim strDateFileName As String
Dim strBackupName As String
Dim strDatabaseName As String
'uses the findsource, getpath, and getfile functions
'to determine the path and filename of the linked database
LinkPathFile = Mid(FindSource(), 11)
LinkPath = GetPath(LinkPathFile)
LinkFile = GetFile(LinkPathFile)
FileWithoutExtention = Left(LinkFile, InStr(LinkFile, ".") - 1)
'Compact the Back-End database to a temp file.
DBEngine.CompactDatabase LinkPath & LinkFile, LinkPath &
FileWithoutExtention & "Temp.mdb"
'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
'-- Make a datestamp filename like _yyyy-mm-dd.bak from the system date
'-- and add it to the path of the backup folder.
strFolder = GetOpenFile()
strDateFileName = MakeFileName()
strBackupName = strFolder & strDateFileName & ".bak"
strDatabaseName = GetPath(LinkPathFile) & FileWithoutExtention 'Get the
name of the Data file.
DBEngine.CompactDatabase strDatabaseName, strBackupName 'Compact old
Data file and make backup to new location with new name.
'If user clicks Cancel on dialog box do not make backup file.
If Dir(strBackupName) = "" Or Dir(strBackupName) = MakeFileName & ".bak"
Then
'user pressed cancel
Kill strBackupName
Err.Raise cERR_USERCANCEL
Else
'If user enters a name for backup file then inform them that backup was
successful.
myMsgBox "Your DATA file has been successfully backed up to..." & vbCrLf
& vbCrLf & strBackupName, vbOKOnly + vbInformation, "Backup Successful!"
End If
CompactData_End:
Exit Function
CompactData_ERR:
If Err.Number = 3024 Then 'Error 3024 is triggered when the DATA file
can not be found.
MsgBox "Could not locate the DATA file for backup."
End If
End If
If Dir(strBackupName) = "" Or Dir(strBackupName) = MakeFileName & ".bak"
Then
Select Case Err
Case cERR_USERCANCEL:
If myMsgBox("Backup of DATA file was unsuccessful!" & vbCrLf &
vbCrLf & "No location or file name was specified for your Backup file!" &
vbCrLf & vbCrLf & "Safeguard your data by backing it up to some type of
portable media such as: a USB flash drive (JumpDrive, SmartDrive or
TravelDrive), External Backup Hard Drive, CD-R, CD-RW or DVD+/-RW!", _
vbCritical + vbRetryCancel + vbMsgBoxHelpButton, "Backup
Unsuccessful", , 105) = vbRetry Then
CompactBackendData
End If
Resume CompactData_End
Case Else:
MsgBox Err.Description & vbCrLf & vbCrLf & "Compact and Backup of
DATA file was unsuccessful!" & vbCrLf & vbCrLf & "Close all open forms and
try again." & vbCrLf & vbCrLf & "You may have to close and reopen the
database before attempting BACKUP again."
Resume CompactData_End
End Select
End If
End Function
'=====End Code============
This code works on Windows XP PCs but does NOT work on Vista.
Like Jack said, first step is to see
whether the BE.mdb has an ldb file associated with it. If it does, don't try
to back it up. Since you indcate that your FE relinks the BE tables on
startup, you might want to go so far as to drop the tables from the FE prior
to attempting the backup.
Another thing you might want to consider is adding the ability to force
other users off, so you can execute the backup.
Does not apply to my situation.
I generally have a table
(db_Parameters) which contains a field (InMaintenance - Y/N) which is
defaulted to False. When I set check this box on my Admin form, it causes a
series of events to occur.
In the startup form of my applications, I include a Timer event that checks
every minute or so to see what the status of [InMaintenance] is (I also do
this in the startup forms open event). If [InMaintenance] = True then I
don't allow the user to open the application. If the application is already
open, it displays a warning message and starts a countdown timer which pops
up every two minutes (for 10-15 minutes). When the countdown timer reaches
zero, the application methodically closes all of the forms (in reverse to the
order they were opened), undoing the changes to the current record.
As stated before this problem only occurs on machines running Vista. It does
not happen on Windows XP machines. The backup works on Windows XP.
Any ideas Dale?