MakeReplica Method Example

This function uses the MakeReplica method to create an additional replica of an existing Design Master. The intOptions argument can be a combination of the constants dbRepMakeReadOnly and dbRepMakePartial, or it can be 0. For example, to create a read-only partial replica, you should pass the value dbRepMakeReadOnly + dbRepMakePartial as the value of intOptions.

Function MakeAdditionalReplica(strReplicableDB As _
    String, strNewReplica As String, intOptions As _
    Integer) As Integer

    Dim dbsTemp As Database
    On Error GoTo ErrorHandler

    Set dbsTemp = OpenDatabase(strReplicableDB)

    ' If no options are passed to
    ' MakeAdditionalReplica, omit the
    ' options argument, which defaults to
    ' a full, read/write replica. Otherwise,
    ' use the value of intOptions.

    If intOptions = 0 Then
        dbsTemp.MakeReplica strNewReplica, _
            "Replica of " & strReplicableDB
    Else
        dbsTemp.MakeReplica strNewReplica, _
            "Replica of " & strReplicableDB, _
            intOptions
    End If

    dbsTemp.Close

ErrorHandler:
    Select Case Err
        Case 0:
            MakeAdditionalReplica = 0
            Exit Function
        Case Else:
            MsgBox "Error " & Err & " : " & Error
            MakeAdditionalReplica = Err
            Exit Function
    End Select

End Function