Reputation: 9546
Using Access 2010, WinXP. I'm trying to update table test
with
Sub testUpdate()
Dim rs As Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("test")
With rs
.AddNew
!field1 = "abc"
!field2 = "def"
.Update
End With
End Sub
If test
is locked by another user, the procedure runs, and doesn't update the table (which is fine), but also doesn't produce an error. If I do the same operation as a SQL insert statement, e.g.
insert into test (field1,field2) values ("abc","def")
then I get an error message telling me the insert failed due to lock violations. How can I make recordset.update
generate a similar error that I can then handle? There doesn't seem to be any equivalent for dbFailOnError
with Recordset, as far as I can tell.
Upvotes: 2
Views: 345
Reputation: 5003
I think you need to look at setting the recordset type and lock type if you want to trigger the error's e.g:
Currentdb.OpenRecordset("test", dbOpenDynaset, dbPessimistic,)
You can test out different variations of these until you find the one that works, the access built in help will list all the available options.
Upvotes: 1