Microsoft KB Archive/139043

= ACC95: User-Defined Database Properties Are Replicated =

Article ID: 139043

Article Last Modified on 11/17/2000

-

APPLIES TO


 * Microsoft Access 95 Standard Edition

-



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
 Open the sample database Northwind.mdb.  Create a module and type the following line in the Declarations section if it's not already there:

     Option Explicit   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.

 Open the sample database Northwind.mdb. On the Tools menu, point to Replication, and then click Create Replica.</li> Allow Microsoft Access to close and reopen the database.</li> Click No when prompted if you want to create a backup of the Northwind.mdb.</li> 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.</li> Close and re-open the Northwind.mdb Design Master.</li> 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.</li> On the File menu, click Database Properties.</li> Click the Custom tab. Note that the custom property MyProp is included in the list with the value of "Test."</li> Close the Northwind.mdb Design Master and open the replica of Northwind database.</li> On the File menu, click Database Properties.</li> Click the Custom tab. Note that the custom property MyProp is NOT included in the list.</li> Close the Replica of the Northwind database and open the Northwind.mdb Design Master.</li> On the Tools menu, point to Replication, and then click Synchronize Now.</li> Confirm the synchronization process and allow it to complete.</li> Close the Northwind.mdb Design Master and open the replica of Northwind.mdb.</li> On the File menu, click Database Properties.</li> Click the Custom tab. Note that the custom property MyProp is now included in the list with the value of "Test."</li></ol>

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.

<div class="references_section">