Backup problem after DB split

G

Guest

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
 
G

Guest

Hi Alex, Your probably right. Can you tell me how I should change that
function? Here's the code for Exportobject function:

Sub ExportObject(strOutputDatabase As String, _
strType As String, strName As String)

Dim intType As Integer

Select Case strType
Case "Table"
intType = acTable
Case "Query"
intType = acQuery
Case "Form"
intType = acForm
Case "Report"
intType = acReport
Case "Macro"
intType = acMacro
Case "Module"
intType = acModule
End Select

' If export fails, let the user know
On Error Resume Next

DoCmd.CopyObject strOutputDatabase, strName, intType, strName
If Err <> 0 Then
Beep
MsgBox "Unable to backup " & strType & ": " & strName, _
vbOKOnly + vbCritical, "ExportObject"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top