Replicable Property Example

These examples illustrate two situations for using the Replicable Property — on a database and on an object in the database.

This example makes Northwind.mdb a replicable database. It's recommended that you make a back-up copy of Northwind before running this code, and that you adjust the path to Northwind as appropriate to its location on your computer.

Sub MakeDesignMasterX()

   Dim dbsNorthwind As Database
   Dim prpNew As Property

   ' Open database for exclusive access.
   Set dbsNorthwind = OpenDatabase("Northwind.mdb", _
      True)

   With dbsNorthwind

      ' If Replicable property doesn't exist, create it.
      ' Turn off error handling in case property exists.
      On Error Resume Next
      Set prpNew = .CreateProperty("Replicable", _
         dbText, "T")
      .Properties.Append prpNew

      ' Set database Replicable property to True.
      .Properties("Replicable") = "T"

      .Close

   End With

End Sub

This example creates a new TableDef and then makes it replicable. The database must first be replicable for this procedure to work.

Sub CreateReplLocalTableX()

   Dim dbsNorthwind As Database
   Dim tdfNew As TableDef
   Dim fldNew As Field
   Dim prpNew As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' Create a new TableDef named "Taxes".
   Set tdfNew = dbsNorthwind.CreateTableDef("Taxes")
   ' Define a text field named "Grade".
   Set fldNew = tdfNew.CreateField("Grade", dbText, 3)
   ' Append new field to the TableDef.
   tdfNew.Fields.Append fldNew

   ' Add the new TableDef to the database.
   dbsNorthwind.TableDefs.Append tdfNew

   ' Create a new Replicable property for new TableDef.
   Set prpNew = tdfNew.CreateProperty("Replicable", _
      dbText, "T")
   ' Append the Replicable property to the new
   ' TableDef.
   tdfNew.Properties.Append prpNew
   dbsNorthwind.Close

End Sub

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

Sub SetReplicable(tdfTemp As TableDef)

   On Error GoTo ErrHandler

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

   On Error GoTo 0

   Exit Sub

ErrHandler:

   Dim prpNew As Property

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

End Sub