How to determine if the current record is locked?
In Access, I set the RecordLocks property of my form to "Edited Record". User-1 starts editting a record, but goes to lunch for 2 hours, leaving the form openned.
User-2 browses to that record, but when trying to edit, the RECORD SELECTOR shows it cannot be editted because it's locked by the hungry user. Everything works well.
I will now remove the record selector... How can I warn my user that he won't be able to edit that record? If he tries to edit the record, he'll end up with an error - which is normal. I would like to know how I can determine, by code, wheter or not the current record is LOCKED - I would then be able to disable some functionnality on that form (buttons and so on, which I don't want the user to use until the record is not locked anymore).
It wouldn't be as accurate if I would just wait for User-2 to try a modification and catch the error resulting from that.
I was expecting something like "msgbox Me.CurrentRecord.locked". (roughly)
Thanks
Re: How to determine if the current record is locked?
How are you opening your recordset or the type of locking your using?
When you use the .OpenRecordset method you can specify the lockedit
parameter and error trap for a lock on the page. Check out the .LockEdit
property in Access help file. :thumb:
Re: How to determine if the current record is locked?
Thanks for trying to help me.
I am not using any recordsets, I am simply using an Access form, which obsviously has a RecordSource property set to the currently viewed record.
That form has the RecordLocks property set to "Editted Record" (I guess that would mean PESSIMISTIC). That seems to work well because it avoids another user to save changes to that record.
I want to avoid error trapping, since the user might work for 10-15 minutes on the form BEFORE trying to submit all changes (Yes, some controls are not BOUND). It'd be nice if the user could see it's locked as soon as he enters and views a given record. (ie showing a "LOCKED" icon in an image control - or something visual like that). I could even disable the "SUBMIT" button.
Thanks
Re: How to determine if the current record is locked?
Yes I know what you mean. What you can do is in the Form_Current
procedure is to error trap for the locked record. Then if its errors you can
display a padlock icon or such. I dont see any other way around knowing in
advance as Access seems to not know until it tries to place the record into
editmode. :(
HTH
Re: How to determine if the current record is locked?
I just thought of something, let's say the record 666 is LOCKED by a user. Then, in form_current, maybe I could try to open a new temporary recordset on the record 666, in locked mode? Maybe then the recordset would give an error message because the record 666 is already locked and cannot be LOCKED again in that recordset?
If this is not a good solution, I will have to go with the error-trapping solution. To do this, would I absolutely need to try and fill a bound textbox with data? Seems like an odd workaround, but hey, if it works.........
Thanks.
Re: How to determine if the current record is locked?
Thats what I was getting at, but without creating a new temp rs.
Glad to have helped. :thumb:
Re: [Resolved] How to determine if the current record is locked?
Now that I know the record is locked, what about knowing WHO'S locking it? Couldn't find much in the forums. Any idea?
(should a new thread been started over?... still related?)
Thanks
Re: [Resolved] How to determine if the current record is locked?
Same thread is fine, but you may want to Un-Resolve it so others will know to read it.
I am going to bed so I will look into it in the morning.
Later