PartialReplica Property
Applies To
Relation object.
Description
Sets or returns a value on a Relation object indicating whether that relation should be considered when populating a partial replica from a full replica. (Microsoft Jet databases only.)
Settings and Return Values
The setting or return value is a Boolean data type that is True when the relation should be enforced during synchronization.
Remarks
This property enables you to replicate data from the full replica to the partial replica based on relationships between tables. You can use the PartialReplica property when setting the ReplicaFilter property alone can't adequately specify what data should be replicated to the partial. For example, suppose you have a database in which the Customers table has a one-to-many relationship with the Orders table, and you want to configure a partial replica that only replicates orders from customers in the California region (instead of all orders). It is not possible to set the ReplicaFilter property on the Orders table to Region = 'CA' because the Region field is in the Customers table, not the Orders table.
To replicate all orders from the California region, you must indicate that the relation between the Orders and Customers tables will be active during replication. Once you've created a partial replica, the following steps will populate it with all orders from the California region:
- Set the ReplicaFilter property on the Customers TableDef object to "Region = 'CA'".
- Set the value of the PartialReplica property to True on the Relation object corresponding to the relationship between Orders and Customers.
- Invoke the PopulatePartial method.
Caution When you set a replica filter or replica relation, be aware that records in the partial replica that don't satisfy the restriction criteria will be removed from the partial replica, but not from the full replica. For example, suppose you set the ReplicaFilter property on the Customers TableDef in the partial replica to "Region = 'CA'" and you then repopulate the database. This will insert or update all records for California-based customers. If you then reset the ReplicaFilter property to "Region = 'FL'" and repopulate the database, all California region records in the partial replica will be removed, and all records from Florida-based customers will be inserted from the full replica. No records in the full replica will be deleted.
Before setting either the ReplicaFilter or PartialReplica property, it's a good idea to synchronize the partial replica in which you are setting these properties with the full replica. This will ensure that pending changes in the partial replica will be merged into the full replica before any records are removed in the partial replica.
Example
The following code example uses the PartialReplica property to replicate all records representing orders from customers in California:
Sub PartialReplicaX()
' Assumptions: dbsTemp is the partial replica and
' appropriate relationships already exist between
' the tables.
Dim tdfOrders As TableDef
Dim relCustOrd As Relation
Dim dbsTemp As Database
Dim relLoop As Relation
Set dbsTemp = OpenDatabase("Northwind.mdb")
Set tdfOrders = dbsTemp.TableDefs("Orders")
' Find the "Customers to Orders" Relation object.
For Each relLoop In dbsTemp.Relations
If relLoop.Table = "Customers" And _
relLoop.ForeignTable = "Orders" Then
' Set the Relation object's PartialReplica
' property to True.
relLoop.PartialReplica = True
Exit For
End If
Next relLoop
End Sub
Note If you have set a replica filter and a replica relation on the same table, the two act in combination as a logical OR operation, not a logical AND operation. For instance, in the preceding example, the records exchanged during synchronization are all orders greater than $1,000 OR all orders from the California region, not all orders from the California region that are over $1,000.