Recordset.BatchCollisionCount-Eigenschaft (DAO)
Gilt für: Access 2013, Office 2013
Syntax
Ausdruck . BatchCollisionCount
Ausdruck Eine Variable, die ein Recordset-Objekt darstellt.
Bemerkungen
Diese Eigenschaft gibt an, wie viele Datensätze auf Konflikte gestoßen sind oder aus einem anderen Grund bei der letzten Aktualisierung nicht aktualisiert werden konnten. Der Wert dieser Eigenschaft entspricht der Anzahl von Textmarken in der BatchCollisions -Eigenschaft.
Wenn Sie die Bookmark -Eigenschaft des aktiven Recordset -Objekts auf Textmarkenwerte im BatchCollisions-Array festlegen, können Sie zu jedem Datensatz wechseln, bei dem die letzte Update -Batchoperation nicht abgeschlossen werden konnte.
After the collision records are corrected, a batch-mode Update method can be called again. At this point DAO attempts another batch update, and the BatchCollisions property again reflects the set of records that failed the second attempt. Any records that succeeded in the previous attempt are not sent in the current attempt, because they now have a RecordStatus property of dbRecordUnmodified. This process can continue as long as collisions occur, or until you abandon the updates and close the result set.
Beispiel
Dieses Beispiel verwendet die BatchCollisionCount -Eigenschaft und die Update -Methode, um die Batchaktualisierung zu demonstrieren, wenn Konflikte durch Erzwingen der Batchaktualisierung gelöst werden.
Sub BatchX()
Dim wrkMain As Workspace
Dim conMain As Connection
Dim rstTemp As Recordset
Dim intLoop As Integer
Dim strPrompt As String
Set wrkMain = CreateWorkspace("ODBCWorkspace", _
"admin", "", dbUseODBC)
' This DefaultCursorDriver setting is required for
' batch updating.
wrkMain.DefaultCursorDriver = dbUseClientBatchCursor
' Note: The DSN referenced below must be configured to
' use Microsoft Windows NT Authentication Mode to
' authorize user access to the Microsoft SQL Server.
Set conMain = wrkMain.OpenConnection("Publishers", _
dbDriverNoPrompt, False, _
"ODBC;DATABASE=pubs;DSN=Publishers")
' The following locking argument is required for
' batch updating. It is also required that a table
' with a primary key is used.
Set rstTemp = conMain.OpenRecordset( _
"SELECT * FROM roysched", dbOpenDynaset, 0, _
dbOptimisticBatch)
With rstTemp
' Modify data in local recordset.
Do While Not .EOF
.Edit
If !royalty <= 20 Then
!royalty = !royalty - 4
Else
!royalty = !royalty + 2
End If
.Update
.MoveNext
Loop
' Attempt a batch update.
.Update dbUpdateBatch
' If there are collisions, give the user the option
' of forcing the changes or resolving them
' individually.
If .BatchCollisionCount > 0 Then
strPrompt = "There are collisions. " & vbCr & _
"Do you want the program to force " & _
vbCr & "an update using the local data?"
If MsgBox(strPrompt, vbYesNo) = vbYes Then _
.Update dbUpdateBatch, True
End If
.Close
End With
conMain.Close
wrkMain.Close
End Sub