Cliff67
Registered User.
- Local time
- Yesterday, 20:08
- Joined
- Oct 16, 2018
- Messages
- 175
Hi all
I'm not sure if this has been posted before but I couldn't find it. I did try to post it yesterday but it seems to have disappeared.
I've done this before but can't get it working and can't remember how I did it before.
So I've got a continuous form that I want to colour code based on the duration that the Tech Support call have been open (just the open ones) the field called "Duration" is calculated based on Today - date opened = days duration
I have a little function called TrafficColourBars as below
The code is called from the Form_Load event but will colour all records displayed the first colour it can match with the duration.
If I call it from Form_Current the whole form changes on the current record so that is a no go on that one.
Anyone done something similar or what am I missing. Do I need to cycle through each record and set the background based on the Duration criteria?
I'm not sure if this has been posted before but I couldn't find it. I did try to post it yesterday but it seems to have disappeared.
I've done this before but can't get it working and can't remember how I did it before.
So I've got a continuous form that I want to colour code based on the duration that the Tech Support call have been open (just the open ones) the field called "Duration" is calculated based on Today - date opened = days duration
I have a little function called TrafficColourBars as below
Code:
Function TrafficColourBars()
'creates different background colours based on the duration
'set the standard font colour as black
Me.Ticket_Number.ForeColor = vbBlack
Me.DateOpened.ForeColor = vbBlack
Me.Company.ForeColor = vbBlack
Me.Country.ForeColor = vbBlack
Me.Product.ForeColor = vbBlack
Me.Duration.ForeColor = vbBlack
Me.Category.ForeColor = vbBlack
If Me.Duration < 6 Then
Me.Detail.BackColor = 35653 'kind of green '69 139 00
ElseIf Me.Duration > 5 And Me.Duration < 11 Then
Me.Detail.BackColor = 1030655 'type of yellow 255 185 15
ElseIf Me.Duration >= 11 Then
'If the ticket is over 10 days set the font white and the back colour as red
Me.Detail.BackColor = 858083 ' red colour
Me.Ticket_Number.ForeColor = vbWhite
Me.DateOpened.ForeColor = vbWhite
Me.Company.ForeColor = vbWhite
Me.Country.ForeColor = vbWhite
Me.Product.ForeColor = vbWhite
Me.Duration.ForeColor = vbWhite
Me.Category.ForeColor = vbWhite
End If
End Function
The code is called from the Form_Load event but will colour all records displayed the first colour it can match with the duration.
If I call it from Form_Current the whole form changes on the current record so that is a no go on that one.
Anyone done something similar or what am I missing. Do I need to cycle through each record and set the background based on the Duration criteria?