comments inline.
Secret Squirrel said:
Tina,
That's close to what I want. It does work but in reverse.
okay. change the "toggle" line of code to
ctrl.Enabled = Not Me!CheckboxName
so if the checkbox is checkmarked (True) then Enabled = False, and vice
versa.
When I put a check
in the "Void" checkbox I want all the fields to be disabled but only for that
specific record.
you have to run the code in two places: the Void checkbox's AfterUpdate or
Click event, AND the form's Current event. also, you have to consider
whether you want the user to be able to "un-void" a record. if so, you don't
want VBA code to disable that particular checkbox control. to deal with that
issue, try this modified code, as
Dim ctrl As Object
On Error Resume Next
For Each ctrl In Me.Controls
If TypeOf ctrl Is TextBox _
Or TypeOf ctrl Is ComboBox _
Or (TypeOf ctrl Is CheckBox And _
(Not ctrl.Name = "CheckboxName")) Then
ctrl.Enabled = Me!CheckboxName
End If
Next
if you're using a Continuous form, you may still not get the effect you're
hoping for - but i won't go into that unless it is an issue for you.
And I don't want the labels to be disabled, just the fields
themselves. How would I fix this?
AFAIK, that can't be done as long as the label is associated with the
control. (a quick test of "associated": if you click on only the control in
design view, and drag it somewhere, the label moves along with it. bingo,
the label is associated with the control.) when a control is
disabled/enabled, or hidden/shown (Visible property), the label exhibits the
same behavior.
to get around that behavior, you can dis-associate a label from a control.
in design view, click on the control's label only and press Ctrl+c to copy
the label. then click anywhere in the form (not on another control) to
de-select the label, and press Ctrl+v to paste. now you have an identical
label, but it is not associated with any control, so it won't be affected by
anything you do to a control. just delete the original label.
hth