RE: Code Help
From: Bob Rapp (anonymous_at_discussions.microsoft.com)
Date: 05/13/04
- Next message: Alan Fisher: "Date Calc Question"
- Previous message: Byron: "back to main menu"
- In reply to: Froto: "Code Help"
- Next in thread: tina: "Re: Code Help"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 13 May 2004 11:41:06 -0700
This should save you some time. Paste this sub in your code and change the form name. Note: This will change all checkboxes on your form. If there's any checkboxes you don't want changed you can flag them in the Tag event and check the value of ctl.tag in your loop.
Sub ChangeCheckboxes()
Dim ctl As Control
Dim frm As Form
Set frm = Forms!YourFormName
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acCheckBox
if ctl.Value = True then
ctl.BackColor = vbRed
else
ctl.BackColor = vbWhite
end if
End Select
Next
Set frm = Nothing
End Sub
----- Froto wrote: -----
I'm created a calandar in Microsoft access, and have a
checkbox in each sqaure that if selected it changes the
background color to red and if unselected it changes back
to white. Here is the code thats in the on current event
of the form.
Private Sub Form_Current()
If Me!Check1.Value = True Then
Me!ID1.BackColor = vbRed
Else
Me!ID1.BackColor = vbWhite
End If
End Sub
What I need is how to change the code so that it changes
the color for every box selected, the code above only
does 1 box, so if user selects box 1 and box 6 and box 10
it would only change the background for those boxes, I
have 31 boxes each with a checkbox.
Thanks for all the help
- Next message: Alan Fisher: "Date Calc Question"
- Previous message: Byron: "back to main menu"
- In reply to: Froto: "Code Help"
- Next in thread: tina: "Re: Code Help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|