The first step in enabling replication is to
create a design master. A design master is the only
replica in the replica set which can make both schema and data changes, all
other replicas can only make data changes to replicated objects. Making a
database replicable makes the database a design master.
The following listings demonstrate how to make
an existing database replicable.
DAO
Sub DAOMakeDesignMaster()
Dim dbsNorthwind As DAO.Database
Dim prpNew As DAO.Property
' Open database for exclusive access.
Set dbsNorthwind = DBEngine.OpenDatabase(".\NorthWind.mdb", True)
With dbsNorthwind
' If Replicable property doesn't exist, create it.
' Turn on error handling in case property exists.
On Error Resume Next
Set prpNew = .CreateProperty("Replicable", dbText, "T")
.Properties.Append prpNew
' Set database Replicable property to True.
.Properties("Replicable") = "T"
.Close
End With
End Sub
JRO
Sub JROMakeDesignMaster()
Dim repMaster As New JRO.Replica
' Make the Northwind database replicable.
' If successful, this will create a connection to the
' database.
repMaster.MakeReplicable ".\NorthWind.mdb", False
Set repMaster = Nothing
End Sub
The JRO model simplifies the code for making a
database replicable. To make a database replicable using DAO, the database must
be opened, the Replicable property created and appended
to the Properties collection of the database, and then
the property set to "T". With JRO, a database can be made replicable
with a single method, MakeReplicable.
The MakeReplicable
method in JRO has an optional second parameter named ColumnTracking
set to False in the example above. It indicates whether or not changes are
tracked at the column level or row level. DAO did not expose the ability to
track changes at the column level. Therefore, this parameter must be set to
False if you want the same behavior as DAO. See the section, "New Features
in JRO" for more information on column level tracking.
As with DAO, the process of making a database
replicable using JRO cannot be reversed. It is recommended that you make a
backup of your database before performing this operation.
EmoticonEmoticon