Differnet colours on a continuous forms

J

James Frater

Hello All,

I have a continuous form which shows all records over a period of time (day,
month, year) for all the locations we work at. To make navigation easier
through this form I'd like to add in a unbound rectangle that changes it's
backcolour to match the location colour of the record.

Stepping backwards a little bit, for each of the 23 locations we have a
different colour. The colour is kept in number format.

So, I'd like the form to look a little bit like this

Location Box Colour
Lawns 1580217
Rugby1 7619088
Football4 1507468
Rugby1 7619088
Clubhouse 7697781

I've tried differnet bits of code (me.boxLocation.backcolor =
me.locationcolour) in differnet places (on_current) but none of them seem to
work.

Any thoughts or help would be greatly appreciated.

Many thanks

JAMES
 
S

strive4peace

Hi James,

the problem is that you are using a continuous form ... so you cannot
use set color to display differently for each record ... well, you can
-- but it would only be accurate for the current record. Conditional
formatting is currently limited to 3 conditions, so this will not work
either...

what you could do, as this is the case, is to put your rectangle in the
form header or footer so it will only show once -- and use the form
Current event to set BackColor

not exactly what you are looking for...

~~~

if you want to get more detailed with your coding, this might work:

set up 8 rectangles using TextBox controls

use conditional formatting such that the normal back color is the same
as the form section

if you are using color codes and not choosing from the palette, you will
need to use code to set up the conditions.

then, in the underlying RecordSource, I am assuming the color is stored
in a field called Colr

in order to implement this, you will need to be comfortable with VBA...

put code on the form Load event to set up the conditions.

make TEXTBOX controls
BackColor = same as the for Detail BackColor
Enabled --> No
Locked --> Yes

Name --> Box1

here is code to set up just conditional formats for the first "box"

'~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Form_Load()

On Error GoTo Proc_Err

If Me.box1.FormatConditions.Count < 1 Then
'Create first condition.
Me.box1.FormatConditions.Add acExpression, _
acEqual, "[colr] = 1580217"
End If

'change the background color
With Me.box1.FormatConditions(0)
.BackColor = 1580217
End With

If Me.box1.FormatConditions.Count < 2 Then
'Create second condition.
Me.box1.FormatConditions.Add acExpression, _
acEqual, "[colr] = 7619088"
End If

'change the background color
With Me.box1.FormatConditions(1)
.BackColor = 7619088
End With

If Me.box1.FormatConditions.Count < 3 Then
'Create third condition.
Me.box1.FormatConditions.Add acExpression, _
acEqual, "[colr] = 1507468"
End If

'change the background color
With Me.box1.FormatConditions(2)
.BackColor = 1507468
End With


Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " Form_Load : " & Me.Name

Resume Proc_Exit
Resume
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~


WHERE
[colr] is the field or control name with the color number

the boxes will have to be next to each other since they will need to
have the default backcolor set the same as the form

Warm Regards,
Crystal
remote programming and training

Video Tutorials on YouTube!
http://www.youtube.com/user/LearnAccessByCrystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
P

Peter Hibbs

James,

I believe you have used a flex grid control before, would it not do
what you want for this situation.

Peter Hibbs.
 

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