Using a Check box to lock fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to build a data entry form for my associates to use but I want to
have a check box function that is tied to our corporate TERMS and CONDITIONS
that will lock all record sources unless the user Checks the box in
agreement. What would be the best way to go about this?
 
One solution to this to use the .Enabled property of the controls on the
form. The controls would have their .Enabled proerty set to no in design
view and whenever the check box is clicked, enable all the controls. The On
Check Box click code to enable the controls would look something like this:

if checkBoxName = -1 Then 'The check box is selected
control1Name.enabled = true
Control2Name.enabled = true
etc.
Else 'The check box is not selected
control1Name.enabled = false
control2Name.enabled = false
Etc.
End if

If there are many controls on the form, perhaps you could use the same idea
but have the agreement check box on an unbound parent form with the data
entry form
as a subform so you would only have to enable one item, the subform.

HTH!
 
I am trying to build a data entry form for my associates to use but I want to
have a check box function that is tied to our corporate TERMS and CONDITIONS
that will lock all record sources unless the user Checks the box in
agreement. What would be the best way to go about this?

Regarding.. >that will lock all record sources<
I assume you meant lock the controls on the form, not the Form's
record source.

Set the Enabled property of each control (EXCEPT the check box) to No.

A few controls?
Code the CheckBox AfterUpdate event:
[Control1].Enabled = [CheckBox] = -1
[Control2].Enabled = [CheckBox] = -1
etc.

A whole lot of controls?
Code the check box AfterUpdate event:
Dim c as Control
For each c in Me.Controls
If TypeOf c is TextBox or TypeOf c is ComboBox then
c.Enabled = [CheckBoxName]
End If
Next c

You can change .Enabled to .Locked if you wish.
 
Back
Top