Retrieving Replica Properties

The procedure in Hands-On 18-8 examines Microsoft Office Access database files in the specified path and lists their replication properties to the Immediate window.

Table 18-3: List of replica properties checked in Hands-On 18-8




Specifies the type of replica — Full, Partial, Design Master, or database is not replicable. Use the following enumerators: jrReplicaTypeFull jrReplicaTypePartial jrRepTypeDesignMaster jrRepTypeNotReplicable


Unique ID for the Design Master in a replica set.


Number of days that the replica set retains details of deleted records, schema changes, and other information. The default RetentionPeriod is 60 days.


Determines who wins and who loses in case of a synchronization conflict. The priority values range from 0 to 100. The Design Master has a default priority of 90.

The maximum value for priority of any replica is 90 percent of its parent.


Ability to synchronize with other replicas.


Unique ID for each replica in the replica set.

® Hands-On 18-8: Retrieving Replica Properties

1. Switch to the Visual Basic Editor window and insert a new module.

2. In the module's Code window, enter the Get_ReplicaProperties procedure as shown below.

Sub Get_ReplicaProperties(strPath As String) Dim fso As Object Dim mdbFile As Object Dim myFolder As Object Dim typeNum As Integer Dim repName As String Dim repMaster As New JRO.Replica

On Error Resume Next

Set fso = CreateObject("Scripting.FileSystemObject") Set myFolder = fso.GetFolder(strPath) For Each mdbFile In myFolder.Files

If InStr(mdbFile.Name, ".mdb") Then repName = strPath & mdbFile.Name repMaster.ActiveConnection = repName

Select Case repMaster.ReplicaType Case jrRepTypeNotReplicable

Debug.Print repName & " is not replicable."

Creating and Manipulating Databases with ADO

Case jrRepTypeDesignMaster

Debug.Print repName & " is a Design Master." Debug.Print "Design Master Id: " & _

repMaster.DesignMasterID Debug.Print "Retention Period: " & _

repMaster.RetentionPeriod Debug.Print "Priority: " & repMaster.Priority Debug.Print "Visibility: " & repMaster.Visibility Case jrRepTypeFull

Debug.Print repName & " is a Full Replica." Debug.Print "Replica Id: " & repMaster.ReplicaID Debug.Print "Retention Period: " & _

repMaster.RetentionPeriod Debug.Print "Priority: " & repMaster.Priority Debug.Print "Visibility: " & repMaster.Visibility Case jrRepTypePartial

Debug.Print repName & " is a Partial Replica." Debug.Print "Retention Period: " & _

repMaster.RetentionPeriod Debug.Print "Priority: " & repMaster.Priority Debug.Print "Visibility: " & repMaster.Visibility End Select End If Next mdbFile

MsgBox "View Replica Properties in the Immediate window." End Sub

To retrieve replica properties, the above procedure must be able to access your computer's file system. This is done by using the FileSystemObject from the Microsoft Scripting Runtime Library (see Hands-On 18-1). We use the GetFolder method of the FileSystemObject object to return a Folder object corresponding to the folder in a specified path. Then we look at all the .mdb files in this folder and, if the file is replicable, we check the properties listed in Table 18-3.

Notice that the Get_ReplicaProperties procedure takes two required and two optional arguments.

3. Run the Get_ReplicaProperties procedure from the Immediate window by typing the following statement and pressing Enter:

Get_ReplicaProperties currentProject.Path & "\"

0 0

Post a comment