Results 1 to 8 of 8

Thread: How to determine if the current record is locked?

  1. #1

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489

    Resolved 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
    Last edited by Krass; Jan 13th, 2005 at 07:00 PM. Reason: now UN-resolved.
    Chris

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489

    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
    Chris

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489

    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.
    Chris

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489

    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
    Chris

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width