- Local time
- Today, 08:25
- Joined
- Sep 12, 2006
- Messages
- 15,958
When an Access form is bound to the actual recordset you are exposing the user to real data....argh, and a lock on that record. If a user changes the data in that form or a subform the record is automatically saved, yikes.
The best thing about going with unbound forms (i.e. bound to temp tables) is to be able to cancel changes and to enjoy a vast reduction in code, like getting rid of beforeUpdate, Undo, on_this or on_that, etc, not to mention an end to mousewheel scrolling, paging up and down, multi-user lock problems, and a multitude of other issues like updating calculated controls or having to avoid subforms or having to use .enable or .locked all the time.
Don't you get all these problems with your databases with multiple users? How do you get around these issues?
no, you don't get problems with multiple users, with bound forms - you have two basic record locking choices with access, but you could also implement your own system, as you have with sentinels/markers etc in records
access's 2 choices
pessimistic locking and
optimistic locking (default)
with pessimistic locking, access tries to acquire an actual lock on the record to prevent other users reading the record while the lock is in place. my understanding is that because of cluster size/granularity and locality issues - access will actually lock a page(s), rather than a single record so other items near the target record can also become locked. For this reason, and for general performance reasons, it is generally critical to maintain locks only for the minimum time possible, to avoid other users being locked out. You also need a way of being able to recover from a deadlock situation, so a purpose built locking system would need a way of releasing any locks it has already obtained, if it cannot obtain all the locks it needs to complete a transaction.
with optimistic locking, access allows any number of readers/writers to see a record simultaneously. Clearly the only problem occurs with writing changes, as reading is immaterial to this process. so in this scenario, before access writes a record it re-reads it, locked, to see if it changed since you originally read it. If so, it disallows your change and gives you the standard "another user changed your record". Generally, I have found that when I get this message, it's because of a programming error, as you can get this message if you yourself have the same record open in multiple forms.
The truth is, in many years programming with access, I have never had to use anything other than optimisitic record locking.
And because managing record locks is so very complex, I prefer in general to leave it to the database manager (ie the database engine) to do this behind the scenes, as it were.
-----
This is really nothing to do with temporary tables. I use temporary tables, when they provide an easy way to manage a complete process, that a user might want to cancel. Sometimes I can achieve this instead by managing flags in a table.