Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    Lock Record when "Add" button is pressed

    I want to "lock" records as soon as the "add" button is pressed, and the only way to unlock the records is to press a button (or any other object on the form) and once the record is locked all information is grayed out and not available to edit.



    Any time I google lock records in access, I get the generic record locking options about optimistic/pessimistic locking.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Does your "Add" button take you to a new, empty record?

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Yes, once the add button is pressed a new record is opened.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm not sure what you mean by "lock the records" then.

  5. #5
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Once the add button is pressed I want:
    1) all fields on the form to be set to enabled = no
    2) a way on the form to push a button or remove check from tickbox and you are able to edit the record again.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So *after* the user presses the "Add" button you go to a new, empty record and keep them from editing any field on that new record? That does not make a lot of sense to me.

  7. #7
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Once the add button is pressed, I want these changes done to the record they just added:

    1) all fields on the form to be set to enabled = no
    2) a way on the form to push a button or remove check from tickbox and you are able to edit the record again.

  8. #8
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    Why not just set the .AllowEdits property of the form to true or false.

    ie.
    me.allowedits = false
    or
    me.allowedits = true
    or
    Forms!MyFormName.AllowEdits = false
    or
    Forms!MyFormName.AllowEdits = true

    To make the field(s) greyed out though, you may need to refer to the specific fields and make the enabled property false.
    ie.
    Forms!MyFormName!SomeFieldName.enabled = false
    Forms!MyFormName!SomeFieldName.locked = true

    Keep in mind that if you're adding a new record or have a button to go to a new record, you'll need to populate the required fields or populate some field first and then issue a me.requery or refresh command to 'write' that record to the table before you set the allowedits to false (or lock the fields.) Otherwise it could go to a new record and then undo adding a new record if you don't allow some way for the record to actually be created first.

    Seems to me though that you're defeating the purpose of the add button and just making it more difficult for the users to add new records. If I was a user, I would want adding a new record a 1-step process instead of a 2 or 3 step process. (and since I always automatically write the user's loginID and DateEntered to fields in the table when new records are added, I always know when a record was added and by who - hence I don't need to complicate adding a new record for users.)

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If you set the DataEntry property = True then the user can *only* see the new record.

  10. #10
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    I do not see the .AllowUpdates option in the properties of my form?

    I need users to be able to see all records in the form, just want to disable them from modifying the record once they have been added.

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So are you using the NavButtons to move through the table or is your form in ContinuousForm mode?

  12. #12
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    I will be using a combo box and the users will input the ticket # and then they will be taken to the record containing that ticket #.

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    pkstormy's suggestion in Post #8 should do the trick.

  14. #14
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    I do not want to complicate the process, I am just trying to prevent accidental deletion from the table. I know I can have a backup of the table, and can backup regularly etc. but I was thinking that if I locked the record after entry or maybe even 5 or 10 minutes after entry it would save some grief when it comes to accidental deletion?

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Do you have some flag in each record telling you that that record is locked?

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-10-2010, 02:12 PM
  2. Replies: 3
    Last Post: 02-23-2010, 06:32 PM
  3. Creating "Edit Record" link in table column
    By joshearl in forum Forms
    Replies: 1
    Last Post: 12-25-2009, 11:17 AM
  4. Create "reset filter" button
    By vanlanjl in forum Access
    Replies: 0
    Last Post: 03-03-2009, 07:36 AM
  5. "Previous Month" button
    By allochthonous in forum Programming
    Replies: 3
    Last Post: 09-10-2006, 12:15 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