Robert Gracie
Subscriptions at servicexp.com
Sat May 17 21:02:17 CDT 2003
I'm trying to backup an open split back-end using the code below. This is a
"third" db that is opening up a back-end and copying the tables and data to
a newly created db. However I keep getting this error.
7874 SXP Maintenance System can't find the object 'Customer.' Note: SXP
Maintenance is the name of the calling db
My code keeps looking at the current db for the tables. If I copy the table
into this db, all works well..
Help would be much appreciated at this point... Keep in mind this is a very
first revision...:-)
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim x As Integer
Dim Wksp As DAO.Workspace
Dim CurrentDatabase As DAO.Database
Dim MyDatabase As DAO.Database
Dim MyContainer As DAO.Container
Dim MyDocument As Document
Dim I As Integer
Dim J As Integer
Dim txtTable As String
Dim strdbtoSaveName As String
Dim strSavedbtoName As String
Dim strdbtoSavePath As String
Dim strSavedbtoPath As String
Dim strSavetoCompleteString As String
Dim strShortDate As String
Dim strLongDate As String
Dim strSaveName As String
Dim intSaveNameFail As String
Dim strSaveNamePath As String
Dim strTestFile As String
Set db = CurrentDb
Set rst = db.OpenRecordset("tblSysBU", dbOpenDynaset)
strLongDate = Format(Date, "mmmm d, yyyy")
strShortDate = Format(Date, "m-d-yyyy")
With rst
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
'lets get the link information from the table
strdbtoSaveName = !dbtoSaveName
strSavedbtoName = !SavedbtoName
strdbtoSavePath = !dbtoSavePath
strSavedbtoPath = !SavedbtoPath
strSavetoCompleteString = strSavedbtoPath & "\" &
strSavedbtoName
Set Wksp = DBEngine.Workspaces(0) 'OpenDatabase(strdbtoSavePath)
Set CurrentDatabase = Wksp.OpenDatabase(strdbtoSavePath)
'Check for existence of previously backed Up DB.
'and append an incremented number to save name if found
strSaveName = strSavedbtoName
strSaveName = strSaveName & ".mdb"
I = 2
intSaveNameFail = True
Do While intSaveNameFail
strSaveNamePath = strSavedbtoPath & strSaveName
strTestFile = Nz(Dir(strSaveNamePath))
If strTestFile = strSaveName Then
'Create new save name with incremented number
intSaveNameFail = True
strSaveName = strSavedbtoName & CStr(I)
strSaveName = strSaveName & ".mdb"
strSaveNamePath = strSavedbtoPath & strSaveName
I = I + 1
Else
intSaveNameFail = False
End If
Loop
Set MyDatabase = Wksp.CreateDatabase(strSaveNamePath, DB_LANG_GENERAL)
MyDatabase.Close
For J = 0 To CurrentDatabase.Containers.Count - 1
Set MyContainer = CurrentDatabase.Containers(J)
If MyContainer.Name = "Tables" Then
For I = 0 To MyContainer.Documents.Count - 1
Set MyDocument = MyContainer.Documents(I)
txtTable = MyDocument.Name
If Left$(txtTable, 4) <> "Msys" And Left$(txtTable, 3) <>
"qry" Then
DoCmd.CopyObject strSaveNamePath, , acTable,
MyDocument.Name
DoEvents
End If
Next I
End If
Next J
.MoveNext
Loop
End If
End With
cmdOK_Click_Exit:
DoCmd.SetWarnings True
Exit Function
cmdOK_Click_Err:
If Err = 3204 Or Err = 3151 Or Err = 91 Or Err = 7874 Or Err = 3064 Or Err =
3011 Then
Debug.Print (Err.Number & " " & Err.Description)
Resume Next
Else
MsgBox Err.Description
End If