Conditional formatting for a form back colour

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to the back colour of a form to change if a check box has been
true.

So, was wondering firstly if this is possible, and if it is, would anyone
know the code for this? I will also admit that I'm rubbish at code, so a real
idiots guide would be most appreciated.

JAMES
 
Use something like

If Me.CheckBox = True Then
Me.Section(0).BackColor = 0
Else
Me.Section(0).BackColor = 255
End If

Note: You need to select the right color in the condition.
If you want to set the value after you click the check box, then use this
code on the AfterUpdate event of the CheckBox. If you want to update the
color when you move between records then this code need to be added to the
OnCurrent event of the Form.
 
Ofer,

Thanks for the code. I've put it in however, I keep getting the error
message:

"Compile Error: Method or data member not found" and highlights ".checkBox"

So can I just check the process that I need to go through:
1) Go to the properties of the CheckBox
2) Go to the 'Event' tab and click on the 'build' button on the 'After
Update' row
3) Select code builder
4) I then copy the code under the private sub line and change the colour, so
the whole things looks like:

Private Sub TBC_AfterUpdate()

If Me.CheckBox = True Then
Me.Section(0).BackColor = 65535
Else
Me.Section(0).BackColor = 255
End If

End Sub

I am brand new to Access, so your help and patience is greatly appreciated

JAMES

PS The background to this is I need to make the form idiot proof. As people
I work with don't quite understand that if someone has checked the "TBC" box,
it means that the item is not finished, and not to ignore it in the hope that
some-one else will finish it off, the scoundrels!
 
In the example I used CheckBox, you need to change it to the name of your
check box TBC

Private Sub TBC_AfterUpdate()

If Me.TBC = True Then
Me.Section(0).BackColor = 65535
Else
Me.Section(0).BackColor = 255
End If

End Sub
 
ha ha ha ha ha, I think that's a perfect example of how new I am to this
Access Bonanza!!!!

Ofer, legendary, it works beautifully, and there are now no excuses.

Many thanks

JAMES
 
Back
Top