Option Button Programming

M

Michelle

r have a form (with a subform) with an "active" employee and "inactive"
employee checkbox. When a user clicks the "active" employee the background
of the main form remains the same color (this is what I want). When the user
clicks the "inactive" employee checkbox the background of the main form turns
Red (this is also what I want). However, the check boxes don't "toggle"
(meaning both boxes remain checked). I am able to select, then deselect the
"active" button and then select the "inactive" button but I would like the
user to be able to "toggle". When I tried setting up the check boxes in an
option group, the buttons don't remain "checked". The background color
changes, but it does not show which button is checked.

I have a macro set up on the "click" event of the checkbox of the "active"
employee keeping the background color the same, and another one on the
"click" event of the checkbox of the "inactive" employee changing the
background to "red".

Below is the code I have for "After Update" and I also have the same code
set up for the "Current" event.

Private Sub Form_AfterUpdate()
If [Active_Employee] = True Then
[Detail].BackColor = 16764057
Else
[Detail].BackColor = vbRed
End If
End Sub

I know what I'm trying to say just hope I'm explaining it correctly.
Thanks in advance for your help.
 
J

Jim Burke in Novi

You don't want checkboxes for what you're trying to do - you want to use an
option group (on the Toolbox it's the rectangle with an 'xyz' at the top).
Just create a new option group with two option buttons and it will
automatically toggle back and forth deending on which one you click. Then put
you're code for when it changes in the AfterUpdate event of the option group.
You assign a numeric value to each option button (you'll do this when the
option group wizard guides you thru), and then refer to that value in the
event proc. Here's an example of an event proc for one of mine (I used
BeforeUpdate but it probably doesn't really matter if you use before or
after). I have three option buttons in the group, with values of 1, 2 and 3 :

Private Sub optionsOV_BeforeUpdate(Cancel As Integer)

Select Case optionsOV
Case 1
cboOV.RowSource = "qryGetProcsOVEst"
Case 2
cboOV.RowSource = "qryGetProcsOVCons"
Case 3
cboOV.RowSource = "qryGetProcsOVSelf"
End Select

cboOV.Requery
cboOV = Null

End Sub
 

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

Top