Export (0) Print
Expand All

TableDef.ReplicaFilter Property (DAO)

Last modified: June 29, 2011

Applies to: Access 2013 | Office 2013

In this article
Syntax
Remarks
Example

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 Access workspaces only).

expression .ReplicaFilter

expression A variable that represents a TableDef object.

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.

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:

  1. Use the Synchronize method to synchronize your full replica with the partial replica in which the filters are being changed.

  2. Use the ReplicaFilter property to make the desired changes to the replica filter.

  3. 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 Note

If a replica filter has changed, and the Synchronize method is invoked without first invoking PopulatePartial, a trappable error occurs.

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 
 

Show:
© 2015 Microsoft