Choice equals colour

anthonyphillips

Registered User.
Local time
Today, 17:15
Joined
Nov 7, 2007
Messages
50
Hi All

I have a question the revolves around getting colour onto forms.

i have a risk database that shows red, amber and green, what I am looking for is a way to show a box on a form that holds a colour indicator not a word.

thanks

Anthony
 
I presume you have an indicator field in your table somewhere. When you bring a record to screen, again preuming you have a bound form, you can use the Oncurrent event of the form to set the background color of an object to whatever colour is appropriate.

David
 
I was looking for something a little simpler, the forms will be read only so they need to be populated from the table, therefore in the risk indicator section if i have put an "R" the box on the form shows red "A" for Amber and "G" for green. Is this possible ?

Anthony
 
Do you have a field in a table that indicates what the risk level is?

If the answer is Yes then my above solution is correct. Even if the form is read only. The form is changing the colur not the user. The form is responding to what is found in the table. From your description all you want is a splodge of colour on your screen to act as a visual indicator as to the risk level, am I not correct.

David
 
Am using Access 2007 and there is no oncurrent in the vent properties sheet for the risk indicator field, screenshot attached.

Any ideas ?

Anthony
 

Attachments

  • risk options.JPG
    risk options.JPG
    20.6 KB · Views: 197
Last edited:
The on current event relates to the form record the field on the form. This is because you can do many things with many fields every time you visit a different record on the form.
 
ok so I have to build an event (code) to recognise the words red, amber and green it will then recognise the words when the form loads ?

Anthony
 
The simplest method of all for doing this would be to use the built-in conditional formatting - right-click (in design view) on the field containing the indicator, then select 'conditional formatting' - and enter the conditions (i.e. Field Value is equal to Red), then set the fill colour you want for the field.

If you don't actually want to see the text that says 'red' on a background that is red, then set the text colour to red for that condition too - red text in a red box just looks like a red box.

You can set up to three conditional formats per control, which should cover the status indiciators you want here - if you need more, then it is necessary to do it in code (and it may not be possible in some types of forms such as datasheets).

If you want to create the functionality entirely yourself, you could do it like this:
Add a 'rectangle' control to your form - set the style to normal
In the OnCurrent event of your form, insert a bit of code, something like:

Select Case Me.YourStatusControlName.Value
Case Is = "red"
Me.Box1.BackColor = vbRed
Case Is = "red"
Me.Box1.BackColor = &HFFC20E '(orange)
Case Is = "red"
Me.Box1.BackColor = vbGreen
Case Else
Me.Box1.BackColor = &H996633 '(brown)
End Select
 

Users who are viewing this thread

Back
Top Bottom