From: kevcar40 on
hi
I have a query that returns all the products for a department
what i would like to do is colour the fields relating to a product
ie
if producttype = 1 then
all fields = backcolor vbred
all fields = forecolor = vbwhite
elseif producttype = 2 then
all fields = backcolor vbblack
all fields = forecolor = vbwhite
elseif producttype = 3 then
all fields = backcolor vbbgreen
all fields = forecolor = vbwhite
elseif producttype = 4 then
all fields = backcolor vbyellow
all fields = forecolor = vbblack
end if
can this be done on a report ?

thanks

kevin
From: Tom van Stiphout on
On Mon, 11 Jan 2010 06:30:38 -0800 (PST), kevcar40
<kevcar40(a)btinternet.com> wrote:

You could look into Conditional Formatting, but I might write some
code in the Detail_Format event.
To loop over all controls use code like this:
for each control in me.controls
'TODO: set color
next

>hi
>I have a query that returns all the products for a department
>what i would like to do is colour the fields relating to a product
>ie
>if producttype = 1 then
> all fields = backcolor vbred
> all fields = forecolor = vbwhite
>elseif producttype = 2 then
> all fields = backcolor vbblack
> all fields = forecolor = vbwhite
>elseif producttype = 3 then
> all fields = backcolor vbbgreen
> all fields = forecolor = vbwhite
>elseif producttype = 4 then
> all fields = backcolor vbyellow
> all fields = forecolor = vbblack
>end if
>can this be done on a report ?
>
>thanks
>
>kevin
From: kevcar40 on
On 11 Jan, 14:46, Tom van Stiphout <tom7744.no.s...(a)cox.net> wrote:
> On Mon, 11 Jan 2010 06:30:38 -0800 (PST), kevcar40
>
> <kevca...(a)btinternet.com> wrote:
>
> You could look into Conditional Formatting, but I might write some
> code in the Detail_Format event.
> To loop over all controls use code like this:
> for each control in me.controls
>   'TODO: set color
> next
>
>
>
> >hi
> >I have a query that returns all the products for a department
> >what i would like to do is colour the fields relating to a product
> >ie
> >if producttype = 1 then
> >  all fields = backcolor vbred
> >  all fields = forecolor = vbwhite
> >elseif producttype = 2 then
> >  all fields = backcolor vbblack
> >  all fields = forecolor = vbwhite
> >elseif producttype = 3 then
> >  all fields = backcolor vbbgreen
> >  all fields = forecolor = vbwhite
> >elseif producttype = 4 then
> >  all fields = backcolor vbyellow
> >  all fields = forecolor = vbblack
> >end if
> >can this be done on a report ?
>
> >thanks
>
> >kevin- Hide quoted text -
>
> - Show quoted text -

thanks for reply
conditional formatting only allows 3 conditions,i need 8

Not sure what your code is doing

Txttype (name of textbox holding value to be checked)




From: paii, Ron on

"kevcar40" <kevcar40(a)btinternet.com> wrote in message
news:b41dfe0d-b20f-4604-8895-bc1fda2c51a7(a)m3g2000yqf.googlegroups.com...
> hi
> I have a query that returns all the products for a department
> what i would like to do is colour the fields relating to a product
> ie
> if producttype = 1 then
> all fields = backcolor vbred
> all fields = forecolor = vbwhite
> elseif producttype = 2 then
> all fields = backcolor vbblack
> all fields = forecolor = vbwhite
> elseif producttype = 3 then
> all fields = backcolor vbbgreen
> all fields = forecolor = vbwhite
> elseif producttype = 4 then
> all fields = backcolor vbyellow
> all fields = forecolor = vbblack
> end if
> can this be done on a report ?
>
> thanks
>
> kevin

If all the controls are transparent you can set the background color of the
section. Note section numbers change when you add or remove a section in the
report def. Following is part of the on format event that sets the color for
a row.

Select Case Me![Highlight]

Case "RED":
Me.Section(0).BackColor = 13421823

Case "BLUE":
Me.Section(0).BackColor = 16710065

Case "GREEN":
Me.Section(0).BackColor = 11665318

Case "YELLOW":
Me.Section(0).BackColor = 8454143

Case Else ' White

Me.Section(0).BackColor = 16777215

End Select


From: Tom van Stiphout on
On Mon, 11 Jan 2010 07:17:36 -0800 (PST), kevcar40
<kevcar40(a)btinternet.com> wrote:

What is not clear about it? You wrote that you wanted "�all fields =
backcolor vbred" etc. How are you going to do that other than by:
a: writing a statement for each control, or
b: looping over all controls and setting the color.

I showed you (b). This is how you loop over all controls:
dim ctl as Control
for each control in me.controls
� debug.print ctl.name
next

Experiment with it, and you'll see how it works.
Of course rather than printing the name you will want to set the
color. I left that for you to do:
'TODO: set color

-Tom.
Microsoft Access MVP


>On 11 Jan, 14:46, Tom van Stiphout <tom7744.no.s...(a)cox.net> wrote:
>> On Mon, 11 Jan 2010 06:30:38 -0800 (PST), kevcar40
>>
>> <kevca...(a)btinternet.com> wrote:
>>
>> You could look into Conditional Formatting, but I might write some
>> code in the Detail_Format event.
>> To loop over all controls use code like this:
>> for each control in me.controls
>> � 'TODO: set color
>> next
>>
>>
>>
>> >hi
>> >I have a query that returns all the products for a department
>> >what i would like to do is colour the fields relating to a product
>> >ie
>> >if producttype = 1 then
>> > �all fields = backcolor vbred
>> > �all fields = forecolor = vbwhite
>> >elseif producttype = 2 then
>> > �all fields = backcolor vbblack
>> > �all fields = forecolor = vbwhite
>> >elseif producttype = 3 then
>> > �all fields = backcolor vbbgreen
>> > �all fields = forecolor = vbwhite
>> >elseif producttype = 4 then
>> > �all fields = backcolor vbyellow
>> > �all fields = forecolor = vbblack
>> >end if
>> >can this be done on a report ?
>>
>> >thanks
>>
>> >kevin- Hide quoted text -
>>
>> - Show quoted text -
>
>thanks for reply
>conditional formatting only allows 3 conditions,i need 8
>
>Not sure what your code is doing
>
>Txttype (name of textbox holding value to be checked)
>
>
>