Color on Forms

G

Guest

I got a requst for the colors to change on a form if a certain check box is
checked. So I have two check boxes. I have a domestic check box and a
International check box. When someone checks the domestic check box I want
the background of the form to change white and if someone checks the
International check box I want the background of the form to turn blue. Can
this be done?
 
D

Douglas J. Steele

I'm not sure two check boxes is appropriate here. What does it mean when
you've got both boxes checked or neither checked?

More appropriate would be a single checkbox (chkInternational) that's
checked for International, or unchecked for Domestic.

Private Sub chkInternational_AfterUpdate()
If Me.chkDomestic Then
Me.BackColor = vbBlue
Else
Me.BackColor = vbWhite
End If
End Sub

If chkInternational is bound to a field in your recordset, you'll want the
If-Else-End If construct in the form's Current event as well.

Another alternative would be to have an Option Group with two radio buttons
in it: one for Domestic and one for International. There, the Group would
have a value of, say, 1 for Domestic and 2 for International:

Private Sub optType_AfterUpdate()
Select Case Me.optType
Case 1 ' Domestic
Me.BackColor = vbWhite
Case 2 ' International
Me.BackColor = vbBlue
End Select
End Sub
 
R

ruralguy via AccessMonster.com

Each section of a form has a BackColor property. You can set this property
in the AfterUpdate event of your CheckBox. You only need one CheckBox by the
way and change colors depending on whether it is checked or not. It would
need to be bound to a field in the bound query if you want to remember the
condition and then you would need to check/set the color in the Current event
of the form.
 

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