ConflictTable Property Example

This example uses the ConflictTable property to report the table names that had conflicts during synchronization.

Sub ConflictTableX()

   Dim dbsNorthwind As Database
   Dim tdfTest As TableDef

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Enumerate TableDefs collection and check ConflictTable
   ' property of each.
   For Each tdfTest In dbsNorthwind.TableDefs
      If tdfTest.ConflictTable <> "" Then _
         Debug.Print tdfTest.Name & " had a conflict."
   Next tdfTest

   dbsNorthwind.Close

End Sub

This example opens a Recordset from the conflict table and one from the table that caused the conflict. It then processes the records in these tables, using the RequiredDate field to copy information from one table to the other depending on which record was more recently updated.

Sub ConflictTableX2(dbsResolve As Database)

   Dim tdfTest As TableDef
   Dim rstSource As Recordset
   Dim rstConflict As Recordset
   Dim fldLoop As Field

   Set tdfTest = dbsResolve.TableDefs("Orders")

   If tdfTest.ConflictTable <> "" Then

      Set rstSource = dbsResolve.OpenRecordset( _
         tdfTest.Name, dbOpenTable)
      Set rstConflict = dbsResolve.OpenRecordset( _
         tdfTest.ConflictTable, dbOpenTable)
      rstSource.Index = "[d_Guid]"
      rstConflict.MoveFirst

      Do Until rstConflict.EOF
         rstSource.Seek "=", rstConflict![s_Guid]
         If Not rstSource.NoMatch Then
            If rstSource!RequiredDate < _
                  rstConflict!RequiredDate Then
               On Error Resume Next
                  For Each fldLoop in rstConflict.Fields
                     fldLoop = rstSource(fldLoop.Name)
                  Next fldLoop
               On Error Goto 0
            End If
         End If
         rstConflict.Delete
         rstConflict.MoveNext
      Loop

      rstConflict.Close
      rstSource.Close
   End If

End Sub