>
Dim dbsBiblio As Database, lngResults As Long
Set dbsBiblio = DBEngine.Workspaces(0).OpenDatabase("Biblio.mdb")
dbsBiblio.Execute "Update Titles Set [Year Published] = 1994 " _
& " WHERE Title = 'To Kill an SQL Query' "
lngResults = dbsBiblio.RecordsAffected
Debug.Print lngResults & " records were changed."
dbsBiblio.Close
Example (Microsoft Access)
The following example prints the number of records updated by an action query.
Sub RecordsUpdated()
Dim dbs As Database, qdf As QueryDef
Dim strSQL As String
' Return Database variable that points to current database.
Set dbs = CurrentDb
strSQL = "UPDATE Employees SET Title = " & _
"'Senior Sales Representative' " & _
"WHERE Title = 'Sales Representative';"
' Create new QueryDef.
Set qdf = dbs.CreateQueryDef("UpdateTitles", strSQL)
' Execute QueryDef object.
qdf.Execute
Debug.Print qdf.RecordsAffected
End Sub