TransferDatabase

  • Thread starter Thread starter Shahzad
  • Start date Start date
S

Shahzad

Dear Respected Gurus,

as i learned always from you,

v had some remote sites, where the data we want to come at the end of
day to our head office.
so we want to transfer all data, at least all tables must come to our
head office. what i understand there r so many methods to do this in
access using coding and others like create replications. can any one
tell me hereunder codes how to make this for all the tables, or till
end of the tables to transfer data. plus any one can advice me this
case

=======================
DoCmd.TransferDatabase acExport, "Microsoft Access", _
"E:\salim\Projects\Renewal Notice\old_TMuw.mdb", acTable, "test",
_
"test"
==================

the remote sites r connected thourgh vpn, so v can share/access data
on either ends similar way

rgds,
shahzad
 
I just build a database in code using code I found in the helpfiles, then
fill it with my own table data:

Function CreateDatabaseX()
On Error Resume Next
Dim ws As Workspace
Dim db As Database
Dim strPath As String
strPath = Me!txtPath

' Get default Workspace.
Set ws = DBEngine.Workspaces(0)

' Make sure there isn't already a file with the name of
' the new database.
If Dir(strPath) <> "" Then Kill strPath

' Create a new database
Set db = ws.CreateDatabase(strPath, dbLangGeneral)

db.Close

End Function

Private Sub cmdAddDataTables_Click()
On Error Resume Next

Call CreateDatabaseX

Dim Response As Integer
Dim strPath As String
Dim strSQL As String
Dim db As Database
Dim ws As Workspace
Dim fInTrans As Boolean

On Error GoTo Err_RollbackDB
fInTrans = False

Set ws = DBEngine.Workspaces(0)
Set db = ws.Databases(0)

strPath = Me!txtPath

Response = MsgBox("This will refresh the Web Database with current data" &
Chr(13) & Chr(10) _
& "Do you want to continue?", 65, "Refresh Web")
If Response = vbOK Then

DoCmd.Hourglass True
BeginTrans
On Error GoTo Err_RollbackDB

strSQL = "SELECT tblAddresses.* INTO tblAddresses IN '" & strPath & "'
FROM tblAddresses"
db.Execute strSQL

strSQL = "SELECT tblAddressType.* INTO tblAddressType IN '" & strPath &
"' FROM tblAddressType"
db.Execute strSQL

strSQL = "SELECT tblMemberData.* INTO tblMemberData IN '" & strPath & "'
FROM tblMemberData"
db.Execute strSQL

strSQL = "SELECT tblPeople.* INTO tblPeople IN '" & strPath & "' FROM
tblPeople"
db.Execute strSQL


If MsgBox("Save all changes?", vbQuestion + vbYesNo, " Save New WebDB") =
vbYes Then
ws.CommitTrans '(dbForceOSFlush) ' Commit changes.
DoCmd.Hourglass False
Else
ws.Rollback 'undo changes.
End If

RollbackDB_Exit:
DoCmd.Hourglass False
Set db = Nothing
Set ws = Nothing
Exit Sub

Err_RollbackDB:
MsgBox "There has been an error " & strPath & " was not created",
vbCritical, "ERROR"
If fInTrans Then
ws.Rollback
End If
Resume RollbackDB_Exit

Else
Exit Sub
End If

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top