Creating a checkbox to lock/unlock an entire form and subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BPacey
    New Member
    • Jun 2009
    • 1

    Creating a checkbox to lock/unlock an entire form and subform

    I have created a database that will be used among many users. In order to protect the data, I am trying to create a checkbox that can either lock or unlock the forn and subform for editing. It would also be useful if the background color of the fields changed color when locked. I have created the database in design mode and am not very familiar with VBA. Any insight would be greatly appreciated. Thanks!
  • IT Couple
    New Member
    • May 2009
    • 36

    #2
    Hi
    I'm not sure if the instructions will make sense but.
    for the checks box use after_update event and change for instance this property me.Form.AllowEd its = False
    Regarding changing the background you have to add a loop into the code
    something like that
    dim ctr as control
    for each ctr in me.Form.Control s

    if left(ctr.name,3 ) = "txt" then 'assuming all your text boxes start with txt
    prefix
    ctr.backcolor = vbred
    end if


    Next

    'you can also check background for all text boxes regardless of name using
    ctr.ControlType = acTextBox

    Remember that in the after update event you need 2 kinds of code so you need
    if checkbox = true then

    else

    end if

    I hope it helps
    Emil

    Comment

    Working...