Disable or gray out controls based on option group selection



I have been trying to figure this out and can't seem to find an answer by
searching at the moment.

I have two option groups on my main form. The first is "Person Type". I have
3 checkboxes in the option group. "PersonTypeFrame" is the frame name and
"chkEmployee" (1), "chkPatient" (2), and "chkVisitor" (3) are the 3 options.
What I would like is if the group is null or anything but chkEmployee is
checked, my other option group "EmployeeStatusFrame" will be grayed
out/disabled and also my "txtEmployeeID" text box will be disabled as well.
If the "Employee" option is checked in the first option group I want both of
these controls to be visible and enabled at that time. I have a number data
type for PersonType, EmployeeStatus, and EmployeeID fields in my table.

Here is the code I am playing with for the text box:

Private Sub EmpStatusFrame_AfterUpdate()
If Me.chkEmployee.Enabled = True Then
Me.txtEmployeeID.Enabled = True
Me.txtEmployeeID.Enabled = False
End If
End Sub

Thanks for any help that can be offered. I am sure it is something simple I
have overlooked.


Bob Gajewski


Forget the checkbox - use the frame value:

If PersonTypeFrame = 1 Then
EmployeeTypeFrame.Enabled = True
txtEmployeeID.Enabled = True
EmployeeTypeFrame.Enabled = False
txtEmployeeID.Enabled = False
End If

You will also want to put this coding in the Form_Current() module.

Bob Gajewski


Dang...I had the "1" in quotes when I orignally tried this. Aside from that I
appear to have been basically on the right track. I also didn't realize I
needed to put it in the form_current section as well. I discovered I also
needed to put the code in the "PersonTypeFrame" After_Update event, not the
"EmpStatusFrame" After_Update event.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question