ReplicaFilter Property
Applies To
TableDef object.
Description
Sets or returns a value on a TableDef object within a partial replica that indicates which subset of records is replicated to that table from a full replica. (Microsoft Jet databases only.)
Settings And Return Values
The setting or return value is a String or Boolean that indicates which subset of records is replicated, as specified in the following table:
Value | Description |
|
A string | A criteria that a record in the partial replica table must satisfy in order to be replicated from the full replica. |
True | Replicates all records. |
False | (Default) Doesn't replicate any records. |
Remarks
This property is similar to an SQL WHERE clause (without the word WHERE), but you cannot specify subqueries, aggregate functions (such as Count), or user-defined functions within the criteria.
You can only synchronize data between a full replica and a partial replica. You can't synchronize data between two partial replicas. Also, with partial replication you can set restrictions on which records are replicated, but you can't indicate which fields are replicated.
Usually, you reset a replica filter when you want to replicate a different set of records. For example, when a sales representative temporarily takes over another sales representative's region, the database application can temporarily replicate data for both regions and then return to the previous filter. In this scenario, the application resets the ReplicaFilter property and then repopulates the partial replica.
If your application changes replica filters, you should follow these steps:
- Use the Synchronize method to synchronize your full replica with the partial replica in which the filters are being changed.
- Use the ReplicaFilter property to make the desired changes to the replica filter.
- Use the PopulatePartial method to remove all records from the partial replica and transfer all records from the full replica that meet the new replica filter criteria.
To remove a filter, set the ReplicaFilter property to False. If you remove all filters and invoke the PopulatePartial method, no records will appear in any replicated tables in the partial replica.
Note If a replica filter has changed, and the Synchronize method is invoked without first invoking PopulatePartial, a trappable error occurs.
Example
The following example uses the ReplicaFilter property to replicate only customer records from the California region.
Sub ReplicaFilterX()
' This example assumes the current open database
' is the replica.
Dim tdfCustomers As TableDef
Dim strFilter As String
Dim dbsTemp As Database
Set dbsTemp = OpenDatabase("Northwind.mdb")
Set tdfCustomers = dbsTemp.TableDefs("Customers")
' Synchronize with full replica
' before setting replica filter.
dbsTemp.Synchronize "C:\Sales\Fy96.mdb"
strFilter = "Region = 'CA'"
tdfCustomers.ReplicaFilter = strFilter
dbsTemp.PopulatePartial "C:\Sales\Fy96.mdb"
' Now remove the replica filter (for example purposes
' only).
tdfCustomers.ReplicaFilter = False
' Repopulate the database.
dbsTemp.PopulatePartial "C:\Sales\Data96.mdb"
End Sub