Results 1 to 15 of 15
  1. #1
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69

    Locking records of a form after approval

    I have the forms of my DB in a fe file, which is common for all users - there are not user logins till now as there are very few users



    Certain records need approval after creation and I would like to lock them for editing, after approval. What is the best way to do it? Maybe I could have a version of the form in my computer, where I have Approval field, not visible to the users, which I can use for approval of the records. If I say Yes, the record gets locked till I unlock it

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Is this a split db with Access backend? If you really want to have this tight of control over permissions to edit records, should probably convert to SQLServer or similar database platform.

    You would either have to not display those records to users by filtering or use code to disable/lock form in total or each control. Conditional Formatting can enable/disable tetboxes and comboboxes by record.

    Of course, none of this will prevent users opening tables directly and doing whatever they want.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    Presumably you have a field to indicate a record is approved - name of the approver? Date of approval? Something else?

    So could be as simple as some code in the form current event along these lines

    Me.allowedits=isnull(me.dateapproved)

    I do hope your comment re fe file being common to all users does not mean they are all using the same fe file

  4. #4
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69

    Unhappy

    Hi Ajax

    Unfortunately they are using the same fe file . I intend to make another form for the approver with this code below for locking and the other users will get a display of the status approved/not approved

    Will test this code.

    Thank you

    Anil




    Quote Originally Posted by Ajax View Post
    Presumably you have a field to indicate a record is approved - name of the approver? Date of approval? Something else?

    So could be as simple as some code in the form current event along these lines

    Me.allowedits=isnull(me.dateapproved)

    I do hope your comment re fe file being common to all users does not mean they are all using the same fe file

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by Anil Bagga View Post
    Hi Ajax

    Unfortunately they are using the same fe file .

    Anil
    Best to give them their own FE ASAP, before you have real problems.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    Unfortunately they are using the same fe file
    agree with WGM - give each user their own copy before you hit a corruption problem that can't be resolved. The fact it hasn't happened yet is just luck on your part.

  7. #7
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69
    Everyone uses a copy of the same fe file, not the same file. Sorry for the lack of clarity.

    I intend to have a new form in the fe file of the Approver which will allow locking of the records using the code suggested by Ajax. The other users will be able to view if the record is approved or not approved

  8. #8
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69
    Just thinking loud, can we not have a password enabled locking of the record. This way I don't need a new form and the password will only be with the approver!

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Password? Sure, and my earlier comments still apply.

    Or match the approver in record with Windows username login.

    Each user should run their own copy of FE. This assumes there can be multiple simultaneous users.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Anil, be aware that if you set
    Code:
    Me.AllowEdits = False
    then you will not be able to use unbound controls (such as combos) to search\navigate records. If you do need that kind of functionality on the form you can set its RecordsetType property to Snapshot or 2.
    Code:
    If YourConditionForLockedRecord=True Then Me.RecordsetType = 2
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  11. #11
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69
    Hi Vlad

    Now this gets complicated and beyond my depth of understanding. I will try this on the weekend and will revert either way - success or failure

    Hi June7
    I dont want to to go to the login route with 4 or 5 users - I dont have the skills and so far this has worked. Fingers crossed.

    I have a master fe file. All users copy this to to their computers and run it from there. They dont have access to the tables in the fe file (No navigation pane). Everyone uses this fe file copy which is on their desktop. When new versions of fe file are made, they simply start using the new fe file and discard the old one. This may not be the best way to do it but end justifies means I guess. Have to work within my constraints

  12. #12
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69
    Hi Vlad,

    The date field in the form is "AuditDate"

    I Added the following code in the current event of the form

    Me.AllowEdits = IsNull(Me.AuditDate)
    If IsNull(Me.AuditDate) = True Then Me.RecordsetType = 2

    The record does get locked but the combo box search in the form header does not work. Also in case the auditor wants to unlock the record and edit it, even he cannot unlock the record! Scrolling records from the bottom of the form is not possible!

    What was desired is a process for the auditor to lock and unlock records on his version of the fe file and the other users will see the audit date as a view only field for them to understand that the record has been audited.

  13. #13
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Anil,

    You should not use both (AllowEdits=False and RecordSetType=2). Having AllowEdits=False will disable the functionality of the unbound search combos. Now the question is how would the program know you are an "auditor"? Do you have a user table with an Auditor (yes\No) field and a way to check the current user against that? Do you use some sort of form-based password scheme where you can "unlock" the form once a valid password is entered?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  14. #14
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69
    Hi Vlad

    I propose to have a separate fe file for the auditor. Barring this there is no other user authentication set currently for different users.

    Everyone copies the master fe file on their computers and runs it from there.

    Is it possible to have an audit authentication in this scenario? Perhaps we can save a password in a table (for ease of change if needed ) and have a toggle button to lock and unlock the record with a password authentication?

  15. #15
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Hi Anil,

    To have a separate file for the auditor(s) will involve duplicating all your changes, even if unrelated to the "auditor" functionality. So I would strongly suggests having only one version of the front-end and implementing some sort of user management; the easiest is as you suggested having one or more passwords saved in a (hidden or custom system) table and simply prompting for the password when users want to edit\add\delete fields\records...

    Or you could have a custom access level security system in place where you could set different "levels" of allowable access (read-only\data-entry\manager=delete allowed, etc.) and for each form you could set each control properties accordingly and\or at the form level (Allow Edits, Allow Deletes ,Allow Additions). There are many examples on the web for this, I have developed my own version over the years (http://forestbyte.com/ms-access-util...access-levels/), but there are many more.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 04-18-2018, 09:02 PM
  2. Locking Field Records
    By nishant.dhruve in forum Access
    Replies: 3
    Last Post: 01-31-2017, 03:48 PM
  3. Help! Locking records
    By jlgray0127 in forum Forms
    Replies: 1
    Last Post: 05-02-2014, 06:56 AM
  4. Replies: 1
    Last Post: 11-27-2012, 02:49 AM
  5. Locking Records in Subform
    By MuskokaMad in forum Forms
    Replies: 1
    Last Post: 04-02-2010, 06:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums