The information in this article applies to:
- Microsoft Access version 7.0
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:
- Open the sample database Northwind.mdb.
- On the File menu, click Database Properties.
- Click the Custom tab.
- In the Name box type "Test" (without the quotation marks).
- Click the arrow next to the Type box, and then click Text.
- In the Value box type "This is a Test" (without the quotation marks).
- 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.
- Allow Microsoft Access to close and reopen the database.
- Click No when prompted if you want to create a backup of the
Northwind.mdb.
- 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.
- Close and re-open the Northwind.mdb Design Master.
- 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.
- On the File menu, click Database Properties.
- Click the Custom tab. Note that the custom property MyProp is included
in the list with the value of "Test."
- Close the Northwind.mdb Design Master and open the replica of
Northwind database.
- On the File menu, click Database Properties.
- Click the Custom tab. Note that the custom property MyProp is NOT
included in the list.
- Close the Replica of the Northwind database and open the Northwind.mdb
Design Master.
- On the Tools menu, point to Replication, and then click Synchronize
Now.
- Confirm the synchronization process and allow it to complete.
- Close the Northwind.mdb Design Master and open the replica of
Northwind.mdb.
- On the File menu, click Database Properties.
- 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.