PopulatePartial Method

       

Synchronizes any changes in a partial replica with the full replica, clears all records in the partial replica, and then repopulates the partial replica based on the current replica filters. (Microsoft Jet databases only.)

Syntax

database.PopulatePartial dbname

The PopulatePartial method syntax has the following parts.

Part

Description

database

An object variable that references the partial replica Database object that you want to populate.

dbname

A string specifying the path and name of the full replica from which to populate records.

 

Remarks

When you synchronize a partial replica with a full replica, it is possible to create "orphaned" records in the partial replica. For example, suppose you have a Customers table with its ReplicaFilter set to "Region = 'CA'". If a user changes a customer's region from CA to NY in the partial replica, and then a synchronization occurs via the Synchronize method, the change is propagated to the full replica but the record containing NY in the partial replica is orphaned because it now doesn't meet the replica filter criteria.

To solve the problem of orphaned records, you can use the PopulatePartial method. The PopulatePartial method is similar to the Synchronize method, but it synchronizes any changes with the full replica, removes all records in the partial replica, and then repopulates the partial replica based on the current replica filters. Even if your replica filters have not changed, PopulatePartial will always clear all records in the partial replica and repopulate it based on the current filters.

Generally, you should use the PopulatePartial method when you create a partial replica and whenever you change your replica filters. If your application changes replica filters, you should follow these steps:

1.Synchronize your full replica with the partial replica in which the filters are being changed.

 

2.Use the ReplicaFilter and PartialReplica properties to make the desired changes to the replica filter.

 

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

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

The PopulatePartial method can only be invoked on a partial replica that has been opened for exclusive access. Furthermore, you can't call the PopulatePartial method from code running within the partial replica itself. Instead, open the partial replica exclusively from the full replica or another database, then call PopulatePartial.

Note Although PopulatePartial performs a one-way synchronization before clearing and repopulating the partial replica, it is still a good idea to call Synchronize before calling PopulatePartial. This is because if the call to Synchronize fails, a trappable error occurs. You can use this error to decide whether or not to proceed with the PopulatePartial method (which removes all records in the partial replica). If PopulatePartial is called by itself and an error occurs while records are being synchronized, records in the partial replica will still be cleared, which may not be the desired result.