Robert said:
Baz,
I tried the following:
Dim returnCount As Long, SQLstr As String
SQLstr = "UPDATE tblRentaldetails SET Returndateandtime = '"
SQLstr = SQLstr & Now()
SQLstr = SQLstr & "' WHERE rentalid = "
SQLstr = SQLstr & Me.txtRentalid
SQLstr = SQLstr & " AND return1 = true"
CurrentDb.Execute SQLstr, dbFailonError
returnCount = CurrentDb.RecordsAffected
The query executes but the returncount always comes up zero. See anything
wrong?
Robert
Yes. CurrentDb is not an object, it is method that returns an object, so
each time you use it you get a new database object. Hence, the database
object which you are checking for
RecordsAffected is not the same database object you used to run the query!
Dim returnCount As Long, SQLstr As String
Dim db As DAO.Database
SQLstr = "UPDATE tblRentaldetails SET Returndateandtime = '"
SQLstr = SQLstr & Now()
SQLstr = SQLstr & "' WHERE rentalid = "
SQLstr = SQLstr & Me.txtRentalid
SQLstr = SQLstr & " AND return1 = true"
Set db = CurrentDb
db.Execute SQLstr, dbFailonError
returnCount = db.RecordsAffected