|
I originally had an extra line in method 2, but i removed it for some reason. I have changed the method slitly to allow the user to save the record after 5 minuits as long as another user has'nt started a edit.
Method 2
1. Create a Datetime field on all tables called "timestamp".
2. On Edit of record check if datetime stamp is less than current date and time if so then Edit if not tell user that record is currently being edited.
3. On allowing of Edit SET the timestamp field to the current date and time plus 5 minutes (Replace TimeStamp with Datetime()+5*60) and STORE the new timestamp in the web page for checking later.
4. On Save, check that the timestamp field is the same as the web form timestamp value. if so update the record as normal but also update the timestamp with the current date and time (Replace TimeStamp with Datetime()) this will re-enable editing. if not tell the user their edit has timed out.
try this new method.
Sorry for the cock up, but it was gone 1:00am in the morning here in the UK when i wrote my first respone and i was half asleep.
I may have two methods you can use to aceive record locking. They both use a datetime stamp.
Method 1
1. Create a Datetime field on all tables called "timestamp".
2. On edit of a record STORE the timestamp field value in the web page for checking later
3. On Save of a record check that the stored timestamp value is the same as the timestamp field value.
4. If timestamps are the same update the record and update the timestamp with the current date and time.
5. If timestamps are different you can give the user the option of forcing the update, or refresh the page with the new timestamp value and get the user to edit again.
This method i thought of because you mentioned a timeout.
Method 2
1. Create a Datetime field on all tables called "timestamp".
2. On Edit of record check if datetime stamp is less than current date and time if so then Edit if not tell user that record is currently being edited.
3. On allowing of Edit SET the timestamp field value to the current date and time plus 5 minutes (Replace TimeStamp with Datetime()+5*60).
4. On Save, check that the timestamp field is greater than the current date and time. if so update the record as normal but also update the timestamp with the current date and time (Replace TimeStamp with Datetime()) this will re-enable editing. if not tell the user their edit has timed out
Both methods will work without any outside program checking and clearing record locks.