UNLOCK control using CHECKBOX

ForrestGump999999
ForrestGump999999 used Ask the Experts™
on
Want to have a CHECKBOX (completed task) and if checked, another field (Date) can be unlocked to fill in.  If not, date field cannot be filled in.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
In the Checkbox's AfterUpdate event:

Private Sub Checkbox1_AfterUpdate()
   Select Case Checkbox1
      Case True
         Me!Date.Enabled = False
         Me!Date.Locked = True
      Case False
         Me!Date.Enabled = True
         Me!Date.Locked = False
   End Select
End Sub
Put this code in the "GOT FOCUS" of the control you want to lock.... with [CHECKBOX] being the control you need to have checked if the [DATEFIELD] is to be active.  

This segregates the code to the specific control (less liklihood of misfires)

Private Sub [DATEFIELD]_GotFocus()
  If [CHECKBOX] = True Then
       [DATEFIELD].Locked = False
   Else
      [DATEFIELD].Locked = True
   End If

End Sub

Author

Commented:
Works fine... thxs!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial