Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change word Yellow to actual color 1

Status
Not open for further replies.

Zonie32

Technical User
Jan 13, 2004
242
US
Hello. I have a report with a text box called Status. We are using Red, Yellow and Green. Right now I have the actual word "Yellow" or "Red" or "Green", but the boss wants the actual box to turn the color.

Is there an easy way to do this in the OnFormat? I don't know how to write the code, but would appreciate any help. thanks.

 
I believe conditional formatting (based on the value being "Yellow", "Red" or "Green") may be in order.

Let them hate - so long as they fear... Lucius Accius
 
if status = "Yellow" then
Status.backcolor = vbyellow
elseif
Status = "Red"
Status.backcolor = vbred
elseif
status = green
Status.backcolor = vbgreen
end id
or something like this it all depends on whether you require the text to be shown


Hope this helps
Hymn
 
Hello. Thanks for that reply. However, I am not quite sure what that means. Do I need to write some formula or code. And if yes, where does that formatting go?
 
Zonie32,

Put that in the onformat event of the appropriate report section. Ie if the box is in the detail level put that in the onformat event of the detail of the report.

Mordja
 
Thanks to all of you for the quick reply. However, I still cannot get this to work. Right now here is what I have in the OnFormat event of the detail section.
I am just trying it with RED for now. When I run the report nothing seems to have happened. I don't see any color change of the Status text box. I just see the word "Red" still. I am using Win XP access 2003.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Status = "Red" Then
Status.BackColor = vbRed
End If

End Sub

I tried using hymn's code but the code doesn't like the elseif part. It highlights it when I debug.
 
sorry forgot about report! try below
Reports("rpt_NameOfReprot")("status").BackColor = vbRed

Hope this helps
Hymn
 
I always use "Me." I believe this code relies on the background being something other than transparent. You must also set the backcolor back to white or every backcolor will be red beginning with the first red status.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Status = "Red" Then
Me.Status.BackColor = vbRed
Else
Me.Status.BackColor = vbWhite
End If

When I have multiple possible values, I use:
Select Case Me.Status
Case "Red"
Me.Status.BackColor = vbRed
Case "Green"
'....
Case Else
Me.Status.BackColor = vbWhite
End Select


Duane
MS Access MVP
[green]Ask a great question, get a great answer.[/green]
[red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
You will need to have the Property BackStyle set to Normal

Hope this helps
Hymn
 
Ok. I figured out how to use Conditional Formatting for this which works just fine. However, the color names are still appearing in the box. Is there a way to not have the actual words showing and just have the text box color show?
 
try
if status = "Yellow" then
Status.backcolor = vbyellow
elseif
Status = "Red"
Status.backcolor = vbred
elseif
status = green
Status.backcolor = vbgreen


with
Property BackStyle set to Normal

if you don't have that set it wont work
I've tested and it works with that set

Hope this helps
Hymn
 
Hello. Thanks for that reply. I put in the detail OnFormat your code. But it doesn't like the "elseif" part. i ran the debug and it highlights it like it doesn't recognize.
I have access 2003 on win xp.
 
Okay. I have gone back and used dhookom's code: which works okay for the color part. it still shows the words yellow, red and green though. i have set the backstyle to normal as suggested. i just cannot for the life of me get the words to disappear! i am getting closer though thanks to everyone's suggestions. i appreciate all of you.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Me.Status
Case "Red"
Me.Status.BackColor = vbRed
Case "Green"
'....
Case Else
Me.Status.BackColor = vbWhite
End Select
 
Try changing the text color to the same color as the background

me.status.forecolor = vbSameAsBackground

I haven't failed, I have just found 10,000 ways that it won't work!
 
Where would I put this bit of code? Do I insert it somewhere between the OnFormat code I have?
 
Put it one line below the code that changes the backcolor say to yellow - on the next line you change the text to yellow too.

Don't forget to turn the text back to black

I haven't failed, I have just found 10,000 ways that it won't work!
 
just try one color ie. red and see if that works
let me now

Hope this helps
Hymn
 
Oh thank you so much txaccess and all of you that responded. I changed the forecolor as suggested and it all works perfectly! Thanks again.
 
Thanks for the star. It's appreciated.

I haven't failed, I have just found 10,000 ways that it won't work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top