"John" <Jo**@nospam.infovis.co.uk> wrote in
news:42*********************@news-text.dial.pipex.com:
What happens when there is a conflict? Does the command come up
with a conflict resolution dialog or raises an error?
No, it doesn't. You must check for conflicts manually, or use code
to check for conflicts.
If there are conflicts, there will be new conflict tables for each
table having conflicts. If the original table was named tblPerson,
the conflict table will be called tblPerson_Conflicts (or maybe it's
tblPerson_Conflict -- I can't remember).
To check for conflicts, do this:
Dim dbLocalReplica As DAO.Database
Dim strLocal As String
Dim tdf As DAO.TableDef
Dim strTableName As String
Dim strConflictTables As String
Dim strMsg As String
strLocal = "[path/name of local replica]"
Set dbLocalReplica = DBEngine(0).OpenDatabase(strLocal)
For Each tdf In dbLocalReplica.TableDefs
strTableName = tdf.Name
If Right(strTableName, 10) = "_Conflicts" Then
strConflictTables = strConflictTables & ", " _
& Left(strTableName, Len(strTableName) - 10)
End If
Next tdf
Set tdf = Nothing
dbLocalReplica.Close
Set dbLocalReplica = Nothing
If Len(strConflictTables) <> 0 Then
strMsg = "There are conflicts in these tables:"
strMsg = strMsg & vbCrLf & " " & vbCrLf
strMsg = strMsg & Mid(strConflictTables, 3)
MsgBox strMsg, vbExclamation, "Conflicts Found!"
End If
You could then open the replica in Access for the end user and the
built-in error dialog for conflicts/errors would pop up.
Or, you could design your own conflict resolver, but that's quite
complex. There are instructions for how to do this in the Access
Developers Handbook, but note that the A2K version uses JRO, which I
simply wouldn't recommend.
The problem with using the A97 version, though, is that replication
was significantly changed from Jet 3.5 to Jet 4.0, with the
elimination of standalone replication errors (data errors and schema
errors), or, more correctly, the treating of replication errors as a
form of conflict.
Just reviewing the code there, however, I see some things I never
knew before, that the MSysSideTables table includes a list of
conflict tables, so, instead of the code above, you could do this:
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strTableList As String
If dbLocalReplica.TableDefs("MSysSideTable").RecordCo unt <> 0 Then
strSQL = "SELECT MSysTableGuids.TableName, "
strSQL = strSQL & "MSysSideTables.SideTable AS ConflictTable "
strSQL = strSQL & "FROM MSysSideTables, MSysTableGuids "
strSQL = strSQL & "WHERE MSysTableGuids.s_GUID=[TableGuid] "
strSQL = strSQL & "ORDER BY MSysTableGuids.TableName;"
Set rs = dbLocalReplica.OpenRecordset(strSQL)
rs.MoveFirst
Do While Not rs.EOF
strTableList = strTableList & vbCrLf & rs!TableName
strTableList = strTableList & ": " & rs!ConflictTable
rs.MoveNext
Loop
End If
strMsg = "There are conflicts in these tables:"
strMsg = strMsg & vbCrLf & " " & vbCrLf
strMsg = strMsg & Mid(strTableList , 3)
MsgBox strMsg, vbExclamation, "Conflicts Found!"
I'm not sure that's easier! I do believe that the test to see if
there are any conflicts will definitely be faster, though, as it
doesn't require a loop through the TableDefs collection.
--
David W. Fenton
http://www.bway.net/~dfenton
dfenton at bway dot net
http://www.bway.net/~dfassoc