KeepLocal Property Example

The following example appends the KeepLocal property to the properties collection of a document object for the Utilities module in the Northwind database. You set this property on an object (such as a table) before a database is made replicable. When the database is converted to a Design Master, the object you specified to remain local will not be dispersed to other members of the replica set. Adjust the path to Northwind.mdb as appropriate to its location on your computer.

Sub KeepLocalNWObjectX()

    Dim dbsNorthwind As Database
    Dim docTemp As Document
    Dim prpTemp As Property

    Set dbsNorthwind = OpenDatabase("Northwind.mdb")
    Set docTemp = dbsNorthwind.Containers("Modules"). _
        Documents("Utility Functions")
    Set prpTemp = doc.CreateProperty("KeepLocal", _
        dbText, "T")
    docTemp.Properties.Append prpTemp
    dbsNorthwind.Close

End Sub

The following code sets the KeepLocal property on the specified TableDef object to "T". If the KeepLocal property doesn't exist, it is created and appended to the table's Properties collection, and given a value of "T".

Sub SetKeepLocal(tdfTemp As TableDef)

    On Error GoTo ErrHandler

    tdfTemp.Properties("KeepLocal") = "T"

    On Error GoTo 0

    Exit Sub

ErrHandler:

    Dim prpNew As Property

    If Err.Number = 3270 Then
        Set prpNew = tdfTemp.CreateProperty("KeepLocal", _
            dbText, "T")
        tdfTemp.Properties.Append prpNew
    Else
        MsgBox "Error " & Err & ": " & Error
    End If

End Sub