Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    lock record so no changes can be made

    I have a combo box that when I select a entry in it I would like it to lock the current record.



    I tried the following code.

    after up date

    me.comboboxname.locked = not me.new record

    this works but it only locks the one combo box and I would like it to lock the record so no changes can be made.

    Thank You

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    You mean after the selection has been updated to the record? Is the combo bound?
    If not, I don't see the point in locking a record after making a combo selection.

    And locking a record isn't the same thing as locking controls, which is what you seem to be wanting.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Locking the record (form) would be done by toggling

    Me.AllowEdits

    and perhaps also the deletions:

    Me.AllowDeletions
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    If the combo selection is " Excepted" than I would like to make it so that no changes can be made to the record.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    So the test would be:

    If Me.ComboName = "Expected" Then

    or with Boolean logic

    Me.Whatever = Me.ComboName = "Expected"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    not sure what you want me to do

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Put 2 and 2 together.

    Me.AllowEdits = Not Me.ComboName = "Expected"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    So what if the control isn't bound? Then it has no value when the form opens.
    I asked a few questions - no answers, so respectfully - you can take it from here. No hard feelings.
    Last edited by Micron; 04-06-2018 at 04:05 PM. Reason: altered answer

  9. #9
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Quote Originally Posted by pbaldy View Post
    Put 2 and 2 together.

    Me.AllowEdits = Not Me.ComboName = "Expected"
    Do I put this in the form property?

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Well, you could start with where you had the other code. In general, I'd probably have it in the current event to handle changing records and in the after update event of the combo.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Quote Originally Posted by pbaldy View Post
    Well, you could start with where you had the other code. In general, I'd probably have it in the current event to handle changing records and in the after update event of the combo.
    i put it in the event for the combo box. But it did not work still can edit record.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    Join Date
    Apr 2017
    Posts
    1,776
    It's unclear what you really want!

    Having a checkbox p.e. chkLocked linked to field Locked can be used to lock current record. For this you AllowEdits and AllowDeletions properties of in AfterUpdate event of chkLocked, and also in Current event of form (when for current record chkLocked, then no edits. Easiest way to allow edits for new record is set default value for chkLocked as FALSE. NB! As editing of record will be restricted, you cant unlock the record.

    Having a unbound checkbox to disable entries/changes allows you to restrict edits and deletions in form, or allow them. Once the selection is made, it remains until it is changed again by new selection, or by Current event (which you also must have again) after selecting new record, when you designed it in this way. You can make the design so, that only new records are editable by default, and you can also enable the form to be editable record-wise.

    For both ways, I advice also disable/enable or lock/unlock all controls linked to source data depending on status of field Locked, or of control chkLocked.
    Last edited by ArviLaanemets; 04-07-2018 at 04:31 AM.

  14. #14
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    What I would like to do is lock the record for being changed. If I had a unbound check box would that lock all records from being changed or just the record selected?
    what code would I just in the unbound check box?
    thank you for your help beyond by knowledge

  15. #15
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849

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

Similar Threads

  1. Save record so no changes can be made
    By angie in forum Programming
    Replies: 5
    Last Post: 04-26-2017, 06:45 AM
  2. Go to record from subform made from query?
    By JQuinnC in forum Access
    Replies: 6
    Last Post: 04-11-2016, 03:28 PM
  3. Replies: 5
    Last Post: 09-23-2013, 08:37 AM
  4. Track employee who made changes to record.
    By FormerJarHead in forum Access
    Replies: 4
    Last Post: 01-09-2013, 04:40 PM
  5. Replies: 9
    Last Post: 05-12-2012, 12:16 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