Status Property Example

This example uses the Status property to display which records have been modified in a batch operation before a batch update has occurred.

Public Sub StatusX()

	Dim rstTitles As ADODB.Recordset
	Dim strCnn As String

	' Open recordset for batch update.
	strCnn = "driver={SQL Server};server=srv;" & _
		"uid=sa;pwd=;database=pubs"
	Set rstTitles = New ADODB.Recordset
	rstTitles.CursorType = adOpenKeyset
	rstTitles.LockType = adLockBatchOptimistic
	rstTitles.Open "titles", strCnn
	
	With rstTitles
		.MoveFirst
		
		' Change the type of psychology titles.
		Do Until .EOF
			If Trim(!Type) = "psychology" Then
				!Type = "self_help"
			End If
			.MoveNext
		Loop
		
		' Display Title ID and status.
		.MoveFirst
		Do Until .EOF
			If .Status = adRecModified Then
				Debug.Print !title_id & " - Modified"
			Else
				Debug.Print !title_id
			End If
			.MoveNext
		Loop

		' Cancel the update because this is a demonstration.
		.CancelBatch
		.Close
	End With

End Sub

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.