Microsoft Jet and Replication Objects

PopulatePartial Method Example

This example demonstrates how to update a replica using the PopulatePartial method.

Public Sub PartialRep()

' This code demonstrates how to create a partial replica with a
' relationship filter and a table filter.
' NOTE: PopulatePartial requires an exclusive connection.

   Dim repMaster As New JRO.Replica
   Dim repPartial As New JRO.Replica
   Dim flt As JRO.Filter
   repMaster.ActiveConnection = _
      "C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb"

   If (Dir("C:\Program Files\" & _
      "Microsoft Office\Office\Samples\" & _
      "Partial of Northwind.mdb") <> "") Then Kill _
      ("C:\Program Files\Microsoft Office\" & _
      "Office\Samples\Partial of Northwind.mdb")

   ' Northwind.mdb is already replicable so you can
   ' create replicas from it.
   repMaster.CreateReplica "C:\Program Files\Microsoft Office\" & _
      "Office\Samples\Partial of Northwind.mdb", _
      "Partial Replica of Northwind", jrRepTypePartial
   
   Set repMaster = Nothing

   ' PopulatePartial requires an exclusive connection to the database.
   repPartial.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=C:\Program Files\Microsoft Office\" & _
      "Office\Samples\Partial of Northwind.mdb;" & _
      "Mode=Share Exclusive"

   repPartial.Filters.Append "Orders", jrFilterTypeRelationship, _
      "CustomersOrders"

   repPartial.Filters.Append "Customers", jrFilterTypeTable, _
      "CustomerID"
   repPartial.PopulatePartial "C:\Program Files\" & _
      "Microsoft Office\Office\Samples\Northwind.mdb"

End Sub