When i run the following it works correctly but if i run the same code in 2 open databases no locking seems to occur. I run the first process and when the message box appears I run the second one. I would expect it to throw an error since the first process has written to a field, but it does not. The second process runs and changes the value in the field and only when i click ok on the message box for process 1 does an error appear saying that the record could not be found for updating. I would like process one to lock the record for editing so when process 2 runs an error is displayed there. Hope this makes sense. Thanks in advance.

Sub testlock()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

cn.ConnectionString = "DRIVER={PostgreSQL ANSI};DATABASE=SolIS;SERVER=localhost;UID=postgres;PWD=p;Port=5432;"
cn.Open
rs.ActiveConnection = cn
rs.CursorType = adOpenDynamic
rs.CursorLocation = adUseServer
rs.LockType = adLockPessimistic
rs.Open "SELECT * FROM matter WHERE code='1234'"
rs!Field1 = "a1"
MsgBox "updating 1"
rs.Update
cn.Close
End Sub