PC Review


Reply
Thread Tools Rate Thread

Conditional Formatting vs Code

 
 
ant1983
Guest
Posts: n/a
 
      17th Jan 2010
Hi,

I have a report that runs off a query - one of my fields is
numPercentageBooked.

I was going to use conditional formatting to change the backcolour of the
cell as per the below:

0% to 65% = Red
66% to 99% = Yellow
100% = Green
More that 100% = Blue

I noticed though that i cant do more than 3 conditions so that wouldnt work.
Besides, it didnt work even if i just did the 3 conditions so not sure what
i did wrong.

So im guessing my alternative is to write some code and put that on the Load
Event.

I have no idea what to write. Please help
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      18th Jan 2010
Does this get you started
http://forums.techguy.org/business-a...ormatting.html

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ant1983" wrote:

> Hi,
>
> I have a report that runs off a query - one of my fields is
> numPercentageBooked.
>
> I was going to use conditional formatting to change the backcolour of the
> cell as per the below:
>
> 0% to 65% = Red
> 66% to 99% = Yellow
> 100% = Green
> More that 100% = Blue
>
> I noticed though that i cant do more than 3 conditions so that wouldnt work.
> Besides, it didnt work even if i just did the 3 conditions so not sure what
> i did wrong.
>
> So im guessing my alternative is to write some code and put that on the Load
> Event.
>
> I have no idea what to write. Please help

 
Reply With Quote
 
ant1983
Guest
Posts: n/a
 
      18th Jan 2010
I wouldnt know how to apply that code plus how do i know what numbers the
colours are?

Ive adjusted as follows but didnt expect it to work (it didnt btw - LOL):

Private Sub Report_Load()
If PercentageBooked Is <=0.65 Then
PercentageBooked.BackColor = 4259584
Else
PercentageBooked.BackColor = -2147483643
End If
End Sub

"ryguy7272" wrote:

> Does this get you started?
> http://forums.techguy.org/business-a...ormatting.html
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.
>
>
> "ant1983" wrote:
>
> > Hi,
> >
> > I have a report that runs off a query - one of my fields is
> > numPercentageBooked.
> >
> > I was going to use conditional formatting to change the backcolour of the
> > cell as per the below:
> >
> > 0% to 65% = Red
> > 66% to 99% = Yellow
> > 100% = Green
> > More that 100% = Blue
> >
> > I noticed though that i cant do more than 3 conditions so that wouldnt work.
> > Besides, it didnt work even if i just did the 3 conditions so not sure what
> > i did wrong.
> >
> > So im guessing my alternative is to write some code and put that on the Load
> > Event.
> >
> > I have no idea what to write. Please help

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      20th Jan 2010
Try something like this:
In your form open event you'll need something like....

Select Case Me.[Field Work]
Case "Red"
Me.YourObjectName.BackColor = 255
Case "Yellow"
Me.YourObjectName.BackColor = 123456
Case "Blue"
Me.YourObjectName.BackColor = 123456
Case "Green"
Me.YourObjectName.BackColor = 123456
End Select
Me.Repaint

Or, send me an email and I'll send you a sample DB that I have.
(E-Mail Removed)

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ant1983" wrote:

> I wouldnt know how to apply that code plus how do i know what numbers the
> colours are?
>
> Ive adjusted as follows but didnt expect it to work (it didnt btw - LOL):
>
> Private Sub Report_Load()
> If PercentageBooked Is <=0.65 Then
> PercentageBooked.BackColor = 4259584
> Else
> PercentageBooked.BackColor = -2147483643
> End If
> End Sub
>
> "ryguy7272" wrote:
>
> > Does this get you started?
> > http://forums.techguy.org/business-a...ormatting.html
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.
> >
> >
> > "ant1983" wrote:
> >
> > > Hi,
> > >
> > > I have a report that runs off a query - one of my fields is
> > > numPercentageBooked.
> > >
> > > I was going to use conditional formatting to change the backcolour of the
> > > cell as per the below:
> > >
> > > 0% to 65% = Red
> > > 66% to 99% = Yellow
> > > 100% = Green
> > > More that 100% = Blue
> > >
> > > I noticed though that i cant do more than 3 conditions so that wouldnt work.
> > > Besides, it didnt work even if i just did the 3 conditions so not sure what
> > > i did wrong.
> > >
> > > So im guessing my alternative is to write some code and put that on the Load
> > > Event.
> > >
> > > I have no idea what to write. Please help

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting -- Need VBA Code Kim M. Microsoft Access VBA Modules 1 15th Mar 2010 08:53 PM
Conditional Formatting via Code ant1983 Microsoft Access VBA Modules 6 19th Jan 2010 06:54 PM
Code for conditional formatting =?Utf-8?B?Q2FsZWRvbmlh?= Microsoft Access Form Coding 13 1st Mar 2007 12:03 AM
Code for conditional formatting =?Utf-8?B?cm9uIGI=?= Microsoft Access 5 20th Jan 2007 09:16 AM
Code to do conditional formatting sc888ter Microsoft Access Form Coding 1 26th Mar 2005 05:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:55 PM.