Synchronize Method Example

These four examples use the Synchronize method to demonstrate one-way and bi-directional exchanges of information between two members of a replica set. They will work if you have converted Northwind.mdb to a Design Master (see the Replicable Property), and created a replica from it. The replica name specified is Nwreplica.mdb. Change the name of the replica to fit your situation, or use the MakeReplica method to create a replica if you need one.

This example sends the changes from the Northwind Design Master to Nwreplica. Adjust the paths to the locations of the files on your computer.

Sub SendChangeToReplicaX()

    Dim dbsNorthwind As Database

    ' Opens the replicable database Northwind.mdb.
    Set dbsNorthwind = OpenDatabase("Northwind.mdb")

    ' Sends data or structural changes to the replica.
    dbsNorthwind.Synchronize "Nwreplica.mdb", _
        dbRepExportChanges

    dbsNorthwind.Close

End Sub

In this example, the replicable database Northwind.mdb receives changes from the replica in the path — Nwreplica. You must run this procedure from the database receiving the changes.

Sub ReceiveChangeX()

    Dim dbsNorthwind As Database

    Set dbsNorthwind = OpenDatabase("Northwind.mdb")

    ' Sends changes from replica to Design Master.
    dbsNorthwind.Synchronize "Nwreplica.mdb", _
        dbRepImportChanges

    dbsNorthwind.Close

End Sub

In this example, changes from both the replicable database Northwind and a replica are exchanged. This is the default argument for this method.

Sub TwoWayExchangeX()

    Dim dbsNorthwind As Database

    Set dbsNorthwind = OpenDatabase("Northwind.mdb")

    ' Sends changes made in each replica to the other.
    dbsNorthwind.Synchronize "Nwreplica.mdb", _
        dbRepImpExpChanges

    dbsNorthwind.Close

End Sub

The following code sample synchronizes two databases over the Internet.

Sub InternetSynchronizeX()

    Dim dbsTemp As Database

    Set dbsTemp = OpenDatabase("C:\Data\OrdEntry.mdb")

    ' Synchronize the local database with the replica on
    ' the Internet server.
    dbsTemp.Synchronize _
        "www.mycompany.myserver.com" _
        & "/files/Orders.mdb", _
        dbRepImpExpChanges + dbRepSyncInternet

    dbsTemp.Close

End Sub