ReplicationConflictFunction Property Example

The following function sets a Microsoft Access property on a DAO object. You can use this function to set the ReplicationConflictFunction property. If the property doesn't already exist in the Properties collection of the UserDefined Document object, Microsoft Access creates and appends it. Note that in order to set this property, you must provide a value of True (–1) for the optional blnDDL argument.

Function SetAccessProperty(obj As Object, strName As String, _
        intType As Integer, varSetting As Variant, _
        Optional blnDDL As Boolean) As Boolean
    Dim prp As Property
    Const intPropNotFound As Integer = 3270

    On Error GoTo Error_SetAccessProperty
    ' Explicitly refer to Properties collection.
    obj.Properties(strName) = varSetting
    obj.Properties.Refresh
    SetAccessProperty = True

Exit_SetAccessProperty:
    Exit Function

Error_SetAccessProperty:
    If Err = intPropNotFound Then
        ' Check whether optional argument has been passed.
        If Not IsMissing(blnDDL) Then
            ' Create property, denote type, set initial value, indicate DDL.
            Set prp = obj.CreateProperty(strName, intType, varSetting, blnDDL)
        Else
            ' Create property, denote type, set initial value.
            Set prp = obj.CreateProperty(strName, intType, varSetting)
        End If
        ' Append Property object to Properties collection.
        obj.Properties.Append prp
        obj.Properties.Refresh
        SetAccessProperty = True
        Resume Exit_SetAccessProperty
    Else
        MsgBox Err & ": " & vbCrLf & Err.Description
        SetAccessProperty = False
        Resume Exit_SetAccessProperty
    End If
End Function

The following procedure calls the SetAccessProperty function to set the ReplicationConflictFunction property:

Sub SetConflictResolver()
    Dim dbs As Database, ctr As Container, doc As Document
    Dim blnReturn As Boolean

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Return reference to Databases container.
    Set ctr = dbs.Containers!Databases
    ' Return reference to SummaryInfo Document object.
    Set doc = ctr.Documents!userdefined
    blnReturn = SetAccessProperty(doc, _
        "ReplicationConflictFunction", dbText, "CustomResolver", True)
    ' Evaluate return value.
    If blnReturn = True Then
        Debug.Print "Property set successfully."
    Else
        Debug.Print "Property not set successfully."
    End If
End Sub