During the process of creating a partial replica using the Partial Replica Wizard, a dialog box is displayed which lists tables that my filter does not directly apply to. As stated in the dialog box, "tables that aren't bold aren't related to the filtered table with referential integrity enforced. To include all records, leave a table selected".
The Partial Replica Wizard does the job well. However, I am unable to do this using VBA. I put the following code in my CreateFilter sub:
For Each td In db.TableDefs
If Not InStr(td.Name, "MSys") > 0 Then
td.ReplicaFilter = True
End If
Next
‘Set the filter on tblUserprefs
Set td = db.TableDefs(“tblUserprefs”)
td.ReplicaFilter = “Site = ‘Box Hill’”
It works insofar as only those users located at 'Box Hill' show up in the replica's Userprefs table (good), and all the unrelated tables ARE present in the partial replica. However, when it comes to setting relationships in the partial replica, the code I am using has no impact on what appears in tblUserdata of the replica:
For Each Rel In db.Relations
If Rel.Table = "tblUserprefs" And Rel.ForeignTable = "tblUserdata" Then
Rel.PartialReplica = True
Else
Rel.PartialReplica = False
End If
Next Rel
I hoped the code would filter the contents of tblUserdata in the replica such that only data related to the users in the Site 'Box Hill' (as established with the filter on tblUserprefs) would appear in the replica.
Any help would be greatly appreciated. I'm losing my sense of humour (and a few kilograms, so it's not all bad)
Quirkey
The Partial Replica Wizard does the job well. However, I am unable to do this using VBA. I put the following code in my CreateFilter sub:
For Each td In db.TableDefs
If Not InStr(td.Name, "MSys") > 0 Then
td.ReplicaFilter = True
End If
Next
‘Set the filter on tblUserprefs
Set td = db.TableDefs(“tblUserprefs”)
td.ReplicaFilter = “Site = ‘Box Hill’”
It works insofar as only those users located at 'Box Hill' show up in the replica's Userprefs table (good), and all the unrelated tables ARE present in the partial replica. However, when it comes to setting relationships in the partial replica, the code I am using has no impact on what appears in tblUserdata of the replica:
For Each Rel In db.Relations
If Rel.Table = "tblUserprefs" And Rel.ForeignTable = "tblUserdata" Then
Rel.PartialReplica = True
Else
Rel.PartialReplica = False
End If
Next Rel
I hoped the code would filter the contents of tblUserdata in the replica such that only data related to the users in the Site 'Box Hill' (as established with the filter on tblUserprefs) would appear in the replica.
Any help would be greatly appreciated. I'm losing my sense of humour (and a few kilograms, so it's not all bad)
Quirkey