K
Karl H
My application had a backup function that worked well. Then I made a network
version and the backup/import functionality no longer works correctly.
When I try to view the backed up data, the tables show an arrow in front of
them, indicating they are referring back to the original DB. So, if I delete
some files on the original DB, the backup files are suddenly missing the
deleted files, too.
Can someone explain how to make the backup be a fresh DB rather than a
reference to the backend?
Here's the code for the Backup:
Sub MakeBackup(ByVal strOutputDatabase As String)
' Makes a backup of objects that have been selected in
' the lboObjects list box using the CopyObject action
Dim dbOutput As Database
Dim intType As Integer
Dim ctlObjects As ListBox
Dim varItem As Variant
Dim strType As String
Dim strName As String
Dim intObjTot As Integer
Dim intObjCnt As Integer
Dim ctlProgress As TextBox
On Error GoTo HandleErr
Set ctlProgress = Me!txtProgress
Set ctlObjects = Me!lboObjects
ctlProgress.Visible = True
ctlProgress = "Initializing..."
intObjTot = ctlObjects.ItemsSelected.Count
' Check to see if the output database exists
If Len(Dir(strOutputDatabase)) > 0 Then
DoCmd.Hourglass False
Beep
If MsgBox("Output Database exists. Overwrite?", _
vbYesNo + vbQuestion) = vbYes Then
Kill strOutputDatabase
Else
Exit Sub
End If
End If
ctlProgress = "Creating " & strOutputDatabase & "..."
DoEvents
Set dbOutput = DBEngine.Workspaces(0). _
CreateDatabase(strOutputDatabase, dbLangGeneral)
dbOutput.Close
' Now backup the selected items
intObjCnt = 0
ctlProgress = "Backing up objects..."
For Each varItem In ctlObjects.ItemsSelected
intObjCnt = intObjCnt + 1
strType = ctlObjects.Column(0, varItem)
strName = ctlObjects.Column(1, varItem)
ctlProgress = "Backing up " & strName & "..."
DoEvents
Call ExportObject(strOutputDatabase, strType, strName)
Next varItem
' Cleanup
ctlProgress = "Backup finished!"
ExitHere:
Exit Sub
HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, , _
"MakeBackup"
End Select
Resume ExitHere
End Sub
Thanks,
Karl
version and the backup/import functionality no longer works correctly.
When I try to view the backed up data, the tables show an arrow in front of
them, indicating they are referring back to the original DB. So, if I delete
some files on the original DB, the backup files are suddenly missing the
deleted files, too.
Can someone explain how to make the backup be a fresh DB rather than a
reference to the backend?
Here's the code for the Backup:
Sub MakeBackup(ByVal strOutputDatabase As String)
' Makes a backup of objects that have been selected in
' the lboObjects list box using the CopyObject action
Dim dbOutput As Database
Dim intType As Integer
Dim ctlObjects As ListBox
Dim varItem As Variant
Dim strType As String
Dim strName As String
Dim intObjTot As Integer
Dim intObjCnt As Integer
Dim ctlProgress As TextBox
On Error GoTo HandleErr
Set ctlProgress = Me!txtProgress
Set ctlObjects = Me!lboObjects
ctlProgress.Visible = True
ctlProgress = "Initializing..."
intObjTot = ctlObjects.ItemsSelected.Count
' Check to see if the output database exists
If Len(Dir(strOutputDatabase)) > 0 Then
DoCmd.Hourglass False
Beep
If MsgBox("Output Database exists. Overwrite?", _
vbYesNo + vbQuestion) = vbYes Then
Kill strOutputDatabase
Else
Exit Sub
End If
End If
ctlProgress = "Creating " & strOutputDatabase & "..."
DoEvents
Set dbOutput = DBEngine.Workspaces(0). _
CreateDatabase(strOutputDatabase, dbLangGeneral)
dbOutput.Close
' Now backup the selected items
intObjCnt = 0
ctlProgress = "Backing up objects..."
For Each varItem In ctlObjects.ItemsSelected
intObjCnt = intObjCnt + 1
strType = ctlObjects.Column(0, varItem)
strName = ctlObjects.Column(1, varItem)
ctlProgress = "Backing up " & strName & "..."
DoEvents
Call ExportObject(strOutputDatabase, strType, strName)
Next varItem
' Cleanup
ctlProgress = "Backup finished!"
ExitHere:
Exit Sub
HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, , _
"MakeBackup"
End Select
Resume ExitHere
End Sub
Thanks,
Karl