Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selectively Locking Fields on a Continuous Form (Access 2000)

    I've got a continuous form that I need to lock or unlock the detail fields depending upon the state of a yes/no
    field in the record (represented as a checkbox on the form). I know how to iterate through the fields on the form, but how would I do this for each record in the query on which the form is based? I've thought about putting code in the On Current event for each field, but this seems like it would incur a great deal of overhead when moving from record to record. Basically, I need to prevent data modifications in records that have been approved by management, but leave unapproved records unlocked.

    Thanks.

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Selectively Locking Fields on a Continuous Form (Access 2000)

    I would just use the oncurrent event to lock /unlock fields depending on the value in the Approved field
    Regards
    John



  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selectively Locking Fields on a Continuous Form (Access 2000)

    I use On Current code frequently for other things. As long as your code is simple, I don't believe you'll see significant slowdowns using it to lock/unlock records.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Selectively Locking Fields on a Continuous Form (Access 2000)

    Let me add that this can get pretty tricky as your code will unlock all records, as continuous forms don't distinguish between records. However as long as you relock the controls in a rigorous fashion, you should be OK - probably on Lost Focus. Another solution might be to either use two subforms, or set a filter to only show unapproved records, and unlock the controls as long as that filter is in effect.
    Wendell

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Selectively Locking Fields on a Continuous Form (Access 2000)

    I suppose that it can't hurt to be very careful, but I would have thought that any attempt to change the value in a different rocord (that I supposed to be locked) will first trigger then oncurrent event again, and that will lock (and/or disable) the control and stop the change.
    Regards
    John



  6. #6
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selectively Locking Fields on a Continuous Form (Access 2000)

    My <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15> worth

    What about using the forms BeforeUpdate event to check if it is allowed to update and Cancelling changes if disallowed?

    I think you can use conditional formatting to selectively lock/unlock controls on a continuous form as well (A2K and higher)
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  7. #7
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selectively Locking Fields on a Continuous Form (Access 2000)

    Hey, I like this idea. Using this method, I can make the check and tell the user what to do if the record is locked. If it's locked I can abandon the changes.

    Thanks to all for the good ideas.

Posting Permissions

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