By default, when a database is made replicable
all objects in that database will be replicated. If you do not want an object
replicated you must indicate that the object should not be replicated (that is,
it should remain local) before you make the database replicable.
In contrast, when you create a new table, query,
form, report, macro, or module at a replica, the object is considered local and
is stored only at that replica. If you want users at other replicas to be able
to use the object, you must make it replicable.
This following listings demonstrate how to
indicate that an object should be kept local when the database is made
replicable.
DAO
Sub DAOKeepObjectLocal()
Dim dbsNorthwind As DAO.Database
Dim docTemp As DAO.Document
Dim prpTemp As DAO.Property
Set dbsNorthwind = DBEngine.OpenDatabase(".\NorthWind.mdb")
Set docTemp = _
dbsNorthwind.Containers("Tables").Documents("Contacts")
Set prpTemp = docTemp.CreateProperty("KeepLocal", dbText, "T")
docTemp.Properties.Append prpTemp
dbsNorthwind.Close
End Sub
JRO
Sub JROKeepObjectLocal()
Dim repMaster As New JRO.Replica
repMaster.ActiveConnection = ".\NorthWind.mdb"
repMaster.SetObjectReplicability "Contacts", "Tables", False
Set repMaster = Nothing
End Sub
This next example shows how to make a new object
in a replica replicable.
DAO
Sub DAOMakeObjectReplicable(strTable As String)
Dim dbsNorthwind As DAO.Database
Dim tdfTemp As DAO.TableDef
Set dbsNorthwind = DBEngine.OpenDatabase(".\NorthWind.mdb")
Set tdfTemp = dbsNorthwind.TableDefs(strTable)
On Error GoTo ErrHandler
tdfTemp.Properties("Replicable") = "T"
On Error GoTo 0
dbsNorthwind.Close
Exit Sub
ErrHandler:
Dim prpNew As DAO.Property
If Err.Number = 3270 Then
Set prpNew = tdfTemp.CreateProperty("Replicable", dbText, "T")
tdfTemp.Properties.Append prpNew
Else
MsgBox "Error " & Err & ": " & Error
End If
End Sub
JRO
Sub JROMakeObjectReplicable(strTable As String)
Dim repMaster As New JRO.Replica
repMaster.ActiveConnection = ".\NorthWind.mdb"
repMaster.SetObjectReplicability strTable, "Tables", True
Set repMaster = Nothing
End Sub
With DAO, two properties, Replicable
and KeepLocal determine whether or not an object is or
will be replicated. Use the KeepLocal property prior to
making the database replicable to indicate that the object should not be made
replicable when the database is made replicable. Use the Replicable
property after the database is made replicable to indicate whether or
not the object should be replicated. DAO requires you to create the properties
using the CreateProperty method of the object's Properties collection before you can set them.
With JRO, the GetObjectReplicability
and SetObjectReplicability methods are used,
both before and after the database is made replicable, to determine or set
whether the object is or will be replicated. The method takes the name of the
object you wish to get or set replicability for, the type of the object, and a
Boolean value that indicates whether it should be kept local or made
replicable.
The following pseudocode is the algorithm for
mapping the DAO KeepLocal and Replicable
properties to the ADO ObjectReplicability.
If DAO.Database.Replicable = 'T'
If DAO.Object.Replicable = 'T'
JRO.ObjectReplicability = True
Else
JRO.ObjectReplicability = False
Else
If DAO.Object.KeepLocal = 'T'
JRO.ObjectReplicability = False
Else
JRO.ObjectReplicability = True
EmoticonEmoticon