Conditional formatting

D

dcummins

I have two option buttons in a group. If 'No Chg' is selected I'd like 6
other fields inactivated. I've read through a lot of the posts and tried
several things, but I'm not getting it to work. It would seem that
[Chgbackgroup]=0 would work, but it does not. Thanks.
 
L

Linq Adams via AccessMonster.com

When you have an option group, you reference it using the name of the frame
that defines the group. Access assigns a number to each item in the group,
starting with 1. So if 'No Chg' is the label of the first item, your code
would be something like this:

Private Sub Form_Current()
If Me.YourFrameName = 1 Then
Me.ControlName1.Locked = True
Me.ControlName1.Enabled = False
Else
Me.ControlName1.Locked = False
Me.ControlName1.Enabled = True
End If
End Sub

Private Sub YourFrameName_AfterUpdate()
If Me.YourFrameName = 1 Then
Me.ControlName1.Locked = True
Me.ControlName1.Enabled = False
Else
Me.ControlName1.Locked = False
Me.ControlName1.Enabled = True
End If
End Sub

The example shows formatting one control (ControlName1) and you'd have to
repeat this for the other 5 controls. "Deactivate" is not really a very clear
term. I used Locked and Enable properties in the example above to render a
textbox visible but unusable. If the controls are something other than
textboxes, you'd have to use properties appropriate to the particular control.
 
Top