Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2014

    Unanswered: Lock Records by Row in A Table from Form

    Hello All,

    I apologize in advance, as I am not "new" to Access, but very, very rusty. I was more of a "user" than programmer, but now I have need to create a database for my small Auto Repair Shop, and I am at a stand still as far as locking a single record goes.

    I will be imputing all the data and will not need to worry about multiple users. But, as perfect as I wish I was, I have already caught myself entering data over existing data. So, I was hoping to find some help as to how I could achieve this. I have searched far and wide on the internet and found some code here and there, but I am not very good at that part of it. I can read it somewhat, but not really.

    So, my question is, how can I create a command button on a form that will lock the record from being edited? It doesn't need to be complex. Just a button to lock the record, then a simple click to unlock it again.

    Is it possible?


  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    you need something that identifies what records can (or cant) be edited
    then I'd set the form's allow edits property to be set appropriately

    Or make your form so that it only allows adding new records

    what you could do is put some code in the forms on current event that locks or unlocks the controls. Assuming you have a control (column) which will always have a value in it eg:-
    dim NewState as boolean ' will hold what he new state for the allow edits property will be
    if isnull(thePrimaryKey) then
    NewState = true 'allow edits
    NewState = false

    public sub SetState(value as boolean)
    me.allowedits = value
    me.allowdeletions = value
    'bear in mind we are always going to allow additions
    'and we are not going to set the dataentry property
    end sub

    you could have a control on the form which either toggles to allow edits property or always enables it for the current record
    in that controls on click event
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2014
    Thanks for the reply.

    I was going to use a command button or a toggle button. Would this code go there or does it go into a module?

Posting Permissions

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