Keeping Objects Local

When your database contains confidential information that most users do not need to see, you may want to prevent specific objects (like a payroll table) from being replicated by setting the object's replicability to False. A newly created object in a Design Master is local by default. If you want this object to be seen by another replica, you must set the object's Replicable property to True (see the preceding section). If you want to make a previously replicated object local, make sure to synchronize first to avoid losing any changes that could have been made to this object in another replica. When you make a replicated object local in the Design Master and then synchronize, the object will be deleted from the replica.

The next hands-on prevents a previously replicated object from being replicated by setting its Replicable property to False using the SetObject-Replicability method that was introduced in the preceding section.

Creating and Manipulating Databases with ADO

| Hands-On 18-6: Preventing an Object from Being Replicated

1. Switch to the Visual Basic Editor window and insert a new module.

2. In the module's Code window, enter the MakeObjectLocal_ InDesignMaster procedure as shown below.

Sub MakeObjectLocal_InDesignMaster(myDb As String, _ objName As String, _ objType As String) Dim repDesignMaster As New JRO.Replica

With repDesignMaster

.ActiveConnection = myDb

.SetObjectReplicability objName, objType, False End With

Set repDesignMaster = Nothing

MsgBox "The object named " & objName & _ " in the collection of " & _ objType & vbCr & "will not be replicated. " & _ "It has been set as local.", vbInformation, _ "Operation Completed"

End Sub

Notice that the above procedure takes three arguments: the full path of your Design Master, the object name, and the object type.

5. Run the MakeObjectLocal_InDesignMaster procedure from the Immediate window by typing the following statement and pressing Enter:

MakeObjectLocal_InDesignMaster CurrentProject.Path & "\DM_Northwind.mdb", "Current Product List", "Tables"

^^ Note: You must type the above statement on one line in the Immediate window.

When you execute this statement, the Current Product List query will no longer be replicable. You can confirm this by opening your Design Master (DM_Northwind.mdb) and switching to the queries pane.

Part II

0 0

Post a comment