Conditional Formatting

M

Mr-Re Man

I have a continuous form where records can be in either 1 of 3 states (Red
Amber or Green)

I can conditionally format all the fields using expression to have the same
colour but I would like to change the background colour of the Detail section
to also go red, amber or green.

Is this possible? and if so could you provide me with some code please :)
 
A

Arvin Meyer [MVP]

Mr-Re Man said:
I have a continuous form where records can be in either 1 of 3 states (Red
Amber or Green)

I can conditionally format all the fields using expression to have the
same
colour but I would like to change the background colour of the Detail
section
to also go red, amber or green.

Is this possible? and if so could you provide me with some code please :)

Here's some air code:

Private Sub Form_Current()
Select Case SomeField.Value
Case 1
Me.Section(0).BackColor = vbRed
Case 27
Me.Section(0).BackColor = vbGreen
Case Else
End Select
End Sub
 
M

Mr-Re Man

Thanks Arvin, I tried the 'air code' with no joy, but tweaked it a little and
ended up with this, I don't know if it is valid, but all the continuous sub
form rows are green.

The ColoursID box is text, rather than an ID number, I set it up this way in
the Table using Lookup Wizard.

Private Sub Form_Current()
Select Case ColoursID.Value
Case 1
Me.Section(Red).BackColor = vbRed
Case 2
Me.Section(Amber).BackColor = vbGold
Case 3
Me.Section(Green).BackColor = vbGreen
Case Else
Me.Section(0).BackColor = vbWhite
End Select
End Sub

I also noticed that when no colour was selected the subforms Form Header
section went Green.

tia
 
L

Linq Adams via AccessMonster.com

If the form/subform is in Datasheet or Continuous View, as most are, you
cannot do this kind of formatting thru code in the Form_Current event. You'd
have to
use the Conditional Formatting from the Format Menu. Unfortunately, the
Detail Section cannot be done using Conditional Formatting.

I've seen hacks where a textbox was placed "under" the entire record, locking
the control, and formatted to a given background color, using CF, but I've
never seen an example that I would really want to use. .
 

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