Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2004
    Location
    Cinci, OH
    Posts
    49

    Unanswered: locking record question

    hey all,

    I am new here and I have already heard great things about this place.

    Well here is my question.

    I have a form that I am using to update a table. In the form I have some combo boxes that I use for selections. Once I have finished selecting the data I want and the record is filled I want that that record to be locked/uneditable. I have tried several things but each time I try something I end up locking the field for the entire form. I only want that record to be locked/uneditable once I am done entering my values. However, when I import the next record I still want to be able to make a selection from those combo boxes and make changes.

    So in simpler terms how can I lock a record after I am done with it with out locking the fields for any new records?

    I have thought about using a sub form for that but I am sure there is an easier way. Is there?

    Any help would be greatly appreciated. Thanks in advance.

    Richard

  2. #2
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    If i read this correctly then do this

    On the after update on the box set the code to be
    ComboName1.Locked = True

    Set that on each combo and when you click the button for a new record set the values on click to read
    ComboName1.Locked = True
    ComboName2.....

    Etc

    Thats how i would do it, i am sure there is probably some more complicated code that can unlock all the combo's at once but by the time you find it you could have written all the code out anyway?

  3. #3
    Join Date
    Aug 2004
    Location
    Cinci, OH
    Posts
    49
    "On the after update on the box set the code to be
    ComboName1.Locked = True

    Set that on each combo and when you click the button for a new record set the values on click to read
    ComboName1.Locked = True
    ComboName2....."

    I think the second part I would set them to False. I did try that. It worked at first. When I select something and that combo box lost focus it locked. Then when I got the new record the combo box would unlock. The problem is the combo box is unlocked for all of the records allowing someone to change one of the other records. When testing this I was on record seven and I changed the combo box in record six. As expected the combo box locked for all of the records. This is close to what I want but not really there. I don't want users to mess everything up.

    I am sure that there is a way to lock the record on the form when you are done with it. Maybe a if statement or somthing.

    Thanks again inadvance for any info or suggestions.

    Richard.

  4. #4
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Right i get you,

    Try this?

    form_load
    If IsNull(FirstComboBox) then
    exit sub
    else
    me.form.allowadditions = false
    me.form.allowedits = false
    me.form.allowdeletions = false

    Also if you add this to the button you use to navigate the records aswell and it should lock them?

  5. #5
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Should have really put there

    form_load
    If IsNull(FirstComboBox) then
    me.form.allowadditions = true
    me.form.allowedits = true
    me.form.allowdeletions = true
    else
    me.form.allowadditions = false
    me.form.allowedits = false
    me.form.allowdeletions = false

  6. #6
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Sorry that should have been

    form_load
    If IsNull(FirstComboBox) then
    me.form.allowadditions = true
    me.form.allowedits = true
    me.form.allowdeletions = true
    else
    me.form.allowadditions = false
    me.form.allowedits = false
    me.form.allowdeletions = false

  7. #7
    Join Date
    Aug 2004
    Location
    Cinci, OH
    Posts
    49
    that may work. but what if I use a button on the form to pull in the next record. Than it would get locked. I have something to start with. Thanks very much.

    Again, any other suggestions or ideas would be great.

    Thanks in advance.

    Richard.

  8. #8
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    i thought you wanted the record to be locked if it has already been done? I though you only wanted new records to be editable and then others to be locked? Am i missing the point completely here?

  9. #9
    Join Date
    Aug 2004
    Location
    Cinci, OH
    Posts
    49
    sorry, I do not think I am explained my self very well. I use a button that runs a query to bring in the new record. When I set the form values to false it worked but then it also locked the button that I use to bring in my new record from teh query. I am sorry if my question is getting out of hand. I have been wrestling with it myself most of the day.

  10. #10
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    What version of access are you using?

  11. #11
    Join Date
    Aug 2004
    Location
    Cinci, OH
    Posts
    49
    2000 sr-1 Professional

  12. #12
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Pretty wierd that, if i make a form so you cant allow additions etc i can still use buttons to run queries etc?

    Could you possibly post you db on here in a zip and i will take a look?

Posting Permissions

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