ACC95: User-Defined Database Properties Are Replicated (139043)



The information in this article applies to:

  • Microsoft Access for Windows 95 7.0

This article was previously published under Q139043

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

The Properties collection of an object is replicated on all databases making up the replication set. This includes any user-defined properties that you add to an object or collection in Microsoft Access version 7.0.

MORE INFORMATION

Every data access object contains a Properties collection, which has certain built-in Property objects. These Property objects (which are often just called properties) uniquely characterize that instance of the object. In addition to the built-in properties, some objects allow you to create and add your own user-defined properties.

You can use database replication to maintain synchronized copies of a database (or replica) either on the same computer or on different computers with different users over a network. When you replicate a database, you create a replica set consisting of the original database and at least one replica that is identical to the original. Each replica and Design Master is capable of creating and manipulating user-defined properties that will be properly synchronized with all databases in the replica set.

There are two methods for adding user-defined properties to a database: you can use the Microsoft Access user interface; or you can use Visual Basic for Applications code.

Using the Microsoft Access User Interface

To add custom properties to a database by using the Microsoft Access user interface follow these steps:
  1. Open the sample database Northwind.mdb.
  2. On the File menu, click Database Properties.
  3. Click the Custom tab.
  4. In the Name box type Test.
  5. Click the arrow next to the Type box, and then click Text.
  6. In the Value box type This is a Test.
  7. Click the Add button.

    NOTE: The custom property Test is now included in the list with the value of "This is a Test."

Using Visual Basic for Applications Code


  1. Open the sample database Northwind.mdb.
  2. Create a module and type the following line in the Declarations section if it's not already there:
          Option Explicit
    						
  3. Type the following procedure:
          Function TestCustomProperty() As Boolean
             On Local Error GoTo TestCustomPropertyErr
             Dim dbs As Database, cnt As Container
             Dim doc As Document, prp As Property
             ' Define Database object, Container and Document.
             Set dbs = CurrentDb()
             Set cnt = dbs.Containers!Databases
             Set doc = cnt.Documents!UserDefined
             ' Refresh the Document object.
             doc.Properties.Refresh
             Set prp = dbs.CreateProperty("MyProp", dbText, "Test")
             doc.Properties.Append prp
             TestCustomProperty = True
             MsgBox "Created Custom Property [MyProp=Test]"
          TestCustomPropertyEnd:
             Exit Function
          TestCustomPropertyErr:
             MsgBox Error$
             Resume TestCustomPropertyEnd
          End Function
    						
To test the behavior of the custom properties using replication, use the following steps to create a replicated database for the sample database Northwind.mdb.
  1. Open the sample database Northwind.mdb.
  2. On the Tools menu, point to Replication, and then click Create Replica.
  3. Allow Microsoft Access to close and reopen the database.
  4. Click No when prompted if you want to create a backup of the Northwind.mdb.
  5. Accept the default folder for the location of the replica database and click OK to close the dialog box.

    You have now created a Design Master and replication database for the sample Northwind.mdb.
  6. Close and re-open the Northwind.mdb Design Master.
  7. Reopen the module you created in steps 1 - 3 of the "Using Visual Basic for Applications Code" section. Open the Debug window, type the following line, and then press ENTER:

    ? TestCustomProperty()


    Note that the message box opens and indicates that the custom property was added.
  8. On the File menu, click Database Properties.
  9. Click the Custom tab. Note that the custom property MyProp is included in the list with the value of "Test."
  10. Close the Northwind.mdb Design Master and open the replica of Northwind database.
  11. On the File menu, click Database Properties.
  12. Click the Custom tab. Note that the custom property MyProp is NOT included in the list.
  13. Close the Replica of the Northwind database and open the Northwind.mdb Design Master.
  14. On the Tools menu, point to Replication, and then click Synchronize Now.
  15. Confirm the synchronization process and allow it to complete.
  16. Close the Northwind.mdb Design Master and open the replica of Northwind.mdb.
  17. On the File menu, click Database Properties.
  18. Click the Custom tab. Note that the custom property MyProp is now included in the list with the value of "Test."
The replicated database(s) will contain all custom properties you have defined through the user interface or through code when you synchronize the databases with the Design Master database.

REFERENCES

For more information about Properties, search on the phrase "Property Collection," and then view any relevant topics using the Answer Wizard from the Microsoft Access 7.0 Help menu.

For more information about Replication, search on the phrase "Briefcase Replication," and then view any relevant topics using the Answer Wizard from the Microsoft Access 7.0 Help menu.

Modification Type:MajorLast Reviewed:11/17/2000
Keywords:kbinfo kbusage KB139043