Applies To Document object.
Description
The ReplicationConflictFunction property enables you to use custom conflict resolution code for resolving data conflicts that occur between replicas upon synchronization. When you set this property, Microsoft Access calls your conflict resolution function, rather than the built-in Conflict Resolver, when the user requests to resolve conflicts.
Settings Set the ReplicationConflictFunction property to a text string that's the name of the Function procedure you wish to call. Note that the setting must be the name of a Function procedure; it can't be the name of a Sub procedure. Unless this property has been set, Microsoft Access calls the Conflict Resolver. To set this property's value for the first time from Visual Basic, you must create the property and append it to the Properties collection of the UserDefined Document object. You should include error-handling code in your procedure to test for the case in which the property doesn't yet exist in the Properties collection. For more information, see the CreateProperty method. When you create and append the ReplicationConflictFunction property, you must also provide a value of True (–1) for the optional DDL argument of the CreateProperty method. This argument ensures that users can't change or delete the new Property object unless they have dbSecWriteDef permissions. If you don't supply a value of True for this argument, your custom conflict resolution code won't be called. To return control to the built-in Conflict Resolver again, remove this property from the Properties collection. You can also add or delete this property on the Custom tab of the DatabaseName Properties dialog box, available by clicking Database Properties on the File menu. Remarks If the same record in a replicated database has been changed in one or more replicas, conflicts will result when you synchronize a replica with the replica set. When you choose to resolve these conflicts, Microsoft Access calls the built-in Conflict Resolver. The wizard presents each conflict to the user, who must manually determine which changed record contains the correct data. If you prefer to automate conflict resolution for your application, you can write custom procedures to resolve conflicts, and then override the built-in functionality by setting the ReplicationConflictFunction property. You should create a single function that acts as a point of entry into your conflict resolution code. Then set the ReplicationConflictFunction property to the name of this function. If you write your own custom conflict resolution code, it must also handle replication design errors and replication data errors. To see an example, open the wizard database Wzcnf80.mda in the Office folder and examine the source code.See Also CreateProperty method ("DAO Language Reference"), Property object ("DAO Language Reference").
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