Synchronizing Replicas

For database replication to be useful, the members of the replica set must communicate with one another in order to remain up to date. Synchronization is the process of making the design and data in all the members identical. Changes made to the existing records in one member are periodically communicated to each of the other members that have that same record. Similarly, records added to or deleted from any one member are communicated to all the other members of the replica set.

You can synchronize one member with another by using either Microsoft Access, Briefcase, Replication Manager, or DAO.

You can keep the members of the replica set synchronized by using the Synchronize method. By specifying the target database’s file name, you can synchronize one user’s replica with another member of the set. You can also perform one-way or two-way synchronizations. For example, you might use the following code to perform a two-way synchronization between members:

Sub SynchronizeDbs(strDbPath As String, strSyncTargetDb As String)
	Dim dbs As Database
		
	Set dbs = OpenDatabase(strDbPath)
	' Synchronize replicas (bidirectional exchange).
	dbs.Synchronize strSyncTargetDb, dbRepImpExpChanges
	dbs.Close
End Sub

If you do not provide a constant value for the exchange argument, the synchronization is bidirectional (import and export).

When Microsoft Jet synchronizes two members of the replica set, it always synchronizes design changes before it synchronizes changes to data. The design of both members must be at the same design version level before data can be synchronized. For example, even if you use dbRepExportChanges to specify that data changes flow only from the current members to the designated target, design changes could be made to the current member if it has a lower design version number than the target member.

If you want to prevent users from making changes to the design of your database, do not put the Design Master on the network server. Instead, keep the Design Master at a network location that is accessible only to you. As you make changes to your application, you can synchronize with a replica on the server and rely on it to pass these changes on to other replicas in the replica set.