Any ideas on how to update a pre existing database with a new one?
I need to get all the records from the old database into a the new one.
------------------
Dave
[email protected]
Printable View
Any ideas on how to update a pre existing database with a new one?
I need to get all the records from the old database into a the new one.
------------------
Dave
[email protected]
If this is Access, than you could link the tables in the old database into the new one, then use update queries (or even cut and paste) to copy all the old data into the new tables. Then delete the table links.
Bash
Sorry, I should have mentioned VB using DAO.
------------------
Dave
[email protected]
Try this:
Private Sub DBBackup()
On Error Resume Next
dbsCamp.Close
Msg = ""
On Error GoTo CompactErr
OrigDBName = DBdir & "\Camp.mdb"
Set dbsCamp = OpenDatabase(DBdir & "\Camp.mdb")
'Show the properties of the original database.
'Msg = "Properties of the current Data Base --> " & DBdir & "\camp.mdb database." & Chr(10)
'With dbsCamp
' Msg = Msg & "Name=" & .Name & ", version " & .Version & Chr(10)
' Msg = Msg & " CollatingOrder = " & .CollatingOrder
' MsgBox Msg
' .Close
'End With
' Make sure there isn't already a file with the
' name of the compacted database.
For J = 1 To 50
If Dir(DBdir & "\Campbkup" & J & ".mdb") = "" Then
NewDBName = DBdir & "\Campbkup" & J & ".mdb"
J = 50
End If
Next J
If Dir(NewDBName) <> "" Then _
Kill NewDBName
dbsCamp.Close
' This statement creates a compact version of the
' Camp database called CampBkup.mdb
DBEngine.CompactDatabase DBdir & "\Camp.mdb", _
NewDBName, dbLangGeneral
Set dbsCamp = OpenDatabase(NewDBName)
Msg = "Properties of the your newly created Backup Data Base" & Chr(10)
With dbsCamp
Msg = Msg & "Name=" & .Name & ", version " & .Version & Chr(10)
Msg = Msg & " CollatingOrder = " & .CollatingOrder
End With
MsgBox Msg & Chr(10) & "Data Base --> " & DBdir & "\camp.mdb successfully backed up " & Chr(10) _
& "to file --> " & NewDBName & "."
dbsCamp.Close
Exit Sub
CompactErr:
If Err.Number <> 0 Then
Msg = Msg & Chr(10)
Msg = Msg & "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
End If
EOJ
End Sub