Custom font colors meeting certain criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to figure out the proper way to display data that meets a
criterion in a different color than the rest of it. For example, I want to
display all CD's that have not been added to my I-Pod directory in red. I
have a “yes/no" field in my data table. I guess the question is, how do I tie
this to the report result? Thank you for any assistance provided.
 
You can color fields in a different color, matching a certain criteria using
the conditional format,
Open the report in design view, select a certain field, from the menu bar
you can select format > conditional format
select the condition and the color
=======================================
Another option will be, using code
On the On Format event of the detail section where all the fields are you
can write the code
If (Condtion) then
me.Field1name.BackColor = Red
me.Field2name.BackColor = Red
me.Field3name.BackColor = Red
else
me.Field1name.BackColor = White
me.Field2name.BackColor = White
me.Field3name.BackColor = White
end if
 
Ofer,

I followed your suggestion for the "conditional format" method and that
worked, however I don't think that I was fully clear on what my intentions
were. I was wanting the entire record to be "Red". My goal is to leave the
Yes/No text as non-visible but my album title and all associated data for
that record would show red on my report.

I hope I am not too vague or confusing with this.

Regardless, thanks for your help.

Terry
 
I thought that this what you want, so you can use the second option I
provided you with
 
I have zero experience with code functions. I'm not sure what to put in the
(Condition) then. I guessed that it should say:

If (iTunes Selection?=no) then (the name of my text blk)
me.album.BackColor = Red
me.year.BackColor = Red
me.format.BackColor = Red
However before I can get past the first line I get a compiler error.
Can you clarifiy any of this for me or am I asking for too much.

Thanks,
Terry
 
Try this

If Me.[iTunes Selection?]=No then '(assuming that iTunes Selection?
is the name of the field)
me.album.BackColor = 255 'Red
me.year.BackColor = 255
me.format.BackColor = 255
else
me.album.BackColor = 16777215 'White
me.year.BackColor = 16777215
me.format.BackColor = 16777215
End If
 
Ofer,

I tried this with several variations on a theme. I take it this is code is
saved as a module? The only thing that I seem to be doing this this is
leaving odd messages at the bottom of my report ie: name?

I appreciate your assistance, I guess I'll just have to screw with this for
a while and maybe it'll "pop" up for me.

Thanks again,
Terry

Ofer said:
Try this

If Me.[iTunes Selection?]=No then '(assuming that iTunes Selection?
is the name of the field)
me.album.BackColor = 255 'Red
me.year.BackColor = 255
me.format.BackColor = 255
else
me.album.BackColor = 16777215 'White
me.year.BackColor = 16777215
me.format.BackColor = 16777215
End If
--
I hope that helped
Good luck


Chief THK said:
I have zero experience with code functions. I'm not sure what to put in the
(Condition) then. I guessed that it should say:

If (iTunes Selection?=no) then (the name of my text blk)
me.album.BackColor = Red
me.year.BackColor = Red
me.format.BackColor = Red
However before I can get past the first line I get a compiler error.
Can you clarifiy any of this for me or am I asking for too much.

Thanks,
Terry
 
One more thing, I'm sorry I didn't notice it before.
You are using name of field that are key words in access, so either change
the name or put them in square brackets.

If Me.[iTunes Selection?]=No then '(assuming that iTunes Selection?
is the name of the field)
me.album.BackColor = 255 'Red
me.[year].BackColor = 255
me.[format].BackColor = 255
else
me.album.BackColor = 16777215 'White
me.[year].BackColor = 16777215
me.[format].BackColor = 16777215
End If

--
I hope that helped
Good luck


Chief THK said:
Ofer,

I tried this with several variations on a theme. I take it this is code is
saved as a module? The only thing that I seem to be doing this this is
leaving odd messages at the bottom of my report ie: name?

I appreciate your assistance, I guess I'll just have to screw with this for
a while and maybe it'll "pop" up for me.

Thanks again,
Terry

Ofer said:
Try this

If Me.[iTunes Selection?]=No then '(assuming that iTunes Selection?
is the name of the field)
me.album.BackColor = 255 'Red
me.year.BackColor = 255
me.format.BackColor = 255
else
me.album.BackColor = 16777215 'White
me.year.BackColor = 16777215
me.format.BackColor = 16777215
End If
--
I hope that helped
Good luck


Chief THK said:
I have zero experience with code functions. I'm not sure what to put in the
(Condition) then. I guessed that it should say:

If (iTunes Selection?=no) then (the name of my text blk)
me.album.BackColor = Red
me.year.BackColor = Red
me.format.BackColor = Red
However before I can get past the first line I get a compiler error.
Can you clarifiy any of this for me or am I asking for too much.

Thanks,
Terry
:

I thought that this what you want, so you can use the second option I
provided you with
--
I hope that helped
Good luck


:

Ofer,

I followed your suggestion for the "conditional format" method and that
worked, however I don't think that I was fully clear on what my intentions
were. I was wanting the entire record to be "Red". My goal is to leave the
Yes/No text as non-visible but my album title and all associated data for
that record would show red on my report.

I hope I am not too vague or confusing with this.

Regardless, thanks for your help.

Terry

:

You can color fields in a different color, matching a certain criteria using
the conditional format,
Open the report in design view, select a certain field, from the menu bar
you can select format > conditional format
select the condition and the color
=======================================
Another option will be, using code
On the On Format event of the detail section where all the fields are you
can write the code
If (Condtion) then
me.Field1name.BackColor = Red
me.Field2name.BackColor = Red
me.Field3name.BackColor = Red
else
me.Field1name.BackColor = White
me.Field2name.BackColor = White
me.Field3name.BackColor = White
end if
--
I hope that helped
Good luck


:

I am trying to figure out the proper way to display data that meets a
criterion in a different color than the rest of it. For example, I want to
display all CD's that have not been added to my I-Pod directory in red. I
have a “yes/no" field in my data table. I guess the question is, how do I tie
this to the report result? Thank you for any assistance provided.
 
Ofer,

I've been fighting with this code for a while and still have not got it to
work
I double checked the field names and they are correct. I thought that maybe
that "Album" should be bracked by [] so I tried that also.

Let me make sure that I'm in the correct format/window.

I start by opening the report, then I select the "Design View" option, then I
select the "Code" button. Then I paste the syntax that you stated
(see below). I placed that in the "(General)" and "(Declarations)" page
of MicroSoft Visual Basic.

I'm sure that I've made this more difficult than
necessary but it seems to be kicking my butt.
All I want to do is turn the darn letters red for that particular record

Option Compare Database

If Me.[iTunes Selection?] = No Then
Me.[Album].BackColor = 255 'Red
Me.[Year].BackColor = 255
Me.[Format].BackColor = 255
Else
Me.[Album].BackColor = 16777215 'White
Me.[Year].BackColor = 16777215
Me.[Format].BackColor = 16777215
End If

I appreciate any additional help you or anyone else can provide.
Terry


Ofer said:
One more thing, I'm sorry I didn't notice it before.
You are using name of field that are key words in access, so either change
the name or put them in square brackets.

If Me.[iTunes Selection?]=No then '(assuming that iTunes Selection?
is the name of the field)
me.album.BackColor = 255 'Red
me.[year].BackColor = 255
me.[format].BackColor = 255
else
me.album.BackColor = 16777215 'White
me.[year].BackColor = 16777215
me.[format].BackColor = 16777215
End If

--
I hope that helped
Good luck


Chief THK said:
Ofer,

I tried this with several variations on a theme. I take it this is code is
saved as a module? The only thing that I seem to be doing this this is
leaving odd messages at the bottom of my report ie: name?

I appreciate your assistance, I guess I'll just have to screw with this for
a while and maybe it'll "pop" up for me.

Thanks again,
Terry

Ofer said:
Try this

If Me.[iTunes Selection?]=No then '(assuming that iTunes Selection?
is the name of the field)
me.album.BackColor = 255 'Red
me.year.BackColor = 255
me.format.BackColor = 255
else
me.album.BackColor = 16777215 'White
me.year.BackColor = 16777215
me.format.BackColor = 16777215
End If
--
I hope that helped
Good luck


:

I have zero experience with code functions. I'm not sure what to put in the
(Condition) then. I guessed that it should say:

If (iTunes Selection?=no) then (the name of my text blk)
me.album.BackColor = Red
me.year.BackColor = Red
me.format.BackColor = Red
However before I can get past the first line I get a compiler error.
Can you clarifiy any of this for me or am I asking for too much.

Thanks,
Terry
:

I thought that this what you want, so you can use the second option I
provided you with
--
I hope that helped
Good luck


:

Ofer,

I followed your suggestion for the "conditional format" method and that
worked, however I don't think that I was fully clear on what my intentions
were. I was wanting the entire record to be "Red". My goal is to leave the
Yes/No text as non-visible but my album title and all associated data for
that record would show red on my report.

I hope I am not too vague or confusing with this.

Regardless, thanks for your help.

Terry

:

You can color fields in a different color, matching a certain criteria using
the conditional format,
Open the report in design view, select a certain field, from the menu bar
you can select format > conditional format
select the condition and the color
=======================================
Another option will be, using code
On the On Format event of the detail section where all the fields are you
can write the code
If (Condtion) then
me.Field1name.BackColor = Red
me.Field2name.BackColor = Red
me.Field3name.BackColor = Red
else
me.Field1name.BackColor = White
me.Field2name.BackColor = White
me.Field3name.BackColor = White
end if
--
I hope that helped
Good luck


:

I am trying to figure out the proper way to display data that meets a
criterion in a different color than the rest of it. For example, I want to
display all CD's that have not been added to my I-Pod directory in red. I
have a “yes/no" field in my data table. I guess the question is, how do I tie
this to the report result? Thank you for any assistance provided.
 
Chief said:
I've been fighting with this code for a while and still have not got it to
work
I double checked the field names and they are correct. I thought that maybe
that "Album" should be bracked by [] so I tried that also.

Let me make sure that I'm in the correct format/window.

I start by opening the report, then I select the "Design View" option, then I
select the "Code" button. Then I paste the syntax that you stated
(see below). I placed that in the "(General)" and "(Declarations)" page
of MicroSoft Visual Basic.

I'm sure that I've made this more difficult than
necessary but it seems to be kicking my butt.
All I want to do is turn the darn letters red for that particular record

Option Compare Database

If Me.[iTunes Selection?] = No Then
Me.[Album].BackColor = 255 'Red
Me.[Year].BackColor = 255
Me.[Format].BackColor = 255
Else
Me.[Album].BackColor = 16777215 'White
Me.[Year].BackColor = 16777215
Me.[Format].BackColor = 16777215
End If


The Declarations area of a module is for declaring module
level variables, not for executable statements.

The code needs to go in the Format event procedure of the
section containing the text box's you're trying to
manipulate, probaly the Detail section.
 
Marshall,

I changed the dropdown menu from (General) to "Detail" and I when I
attempted to open the report I recieved the following msg: "The expression On
Format you entered as teh event property setting produced teh follwoing
error: Invalid Outside Procedure.

Does this mean anything to you?

Thanks, Terry

Marshall Barton said:
Chief said:
I've been fighting with this code for a while and still have not got it to
work
I double checked the field names and they are correct. I thought that maybe
that "Album" should be bracked by [] so I tried that also.

Let me make sure that I'm in the correct format/window.

I start by opening the report, then I select the "Design View" option, then I
select the "Code" button. Then I paste the syntax that you stated
(see below). I placed that in the "(General)" and "(Declarations)" page
of MicroSoft Visual Basic.

I'm sure that I've made this more difficult than
necessary but it seems to be kicking my butt.
All I want to do is turn the darn letters red for that particular record

Option Compare Database

If Me.[iTunes Selection?] = No Then
Me.[Album].BackColor = 255 'Red
Me.[Year].BackColor = 255
Me.[Format].BackColor = 255
Else
Me.[Album].BackColor = 16777215 'White
Me.[Year].BackColor = 16777215
Me.[Format].BackColor = 16777215
End If


The Declarations area of a module is for declaring module
level variables, not for executable statements.

The code needs to go in the Format event procedure of the
section containing the text box's you're trying to
manipulate, probaly the Detail section.
 
Lets try this steps
1. Open the Report in design view
2. Open the properties (press Alt+Enter)
3. Press on the details section where all the fields are
4. One of the properties is "On format" click in it.
5. There is a button on the right with three dots, press on it, choos code
builder
6. Put the code in this sub.

If Me.[iTunes Selection?] = No Then
Me.[Album].BackColor = 255 'Red
Me.[Year].BackColor = 255
Me.[Format].BackColor = 255
Else
Me.[Album].BackColor = 16777215 'White
Me.[Year].BackColor = 16777215
Me.[Format].BackColor = 16777215
End If
I'm not sure if that what you did, but try it
--
I hope that helped
Good luck


Chief THK said:
Marshall,

I changed the dropdown menu from (General) to "Detail" and I when I
attempted to open the report I recieved the following msg: "The expression On
Format you entered as teh event property setting produced teh follwoing
error: Invalid Outside Procedure.

Does this mean anything to you?

Thanks, Terry

Marshall Barton said:
Chief said:
I've been fighting with this code for a while and still have not got it to
work
I double checked the field names and they are correct. I thought that maybe
that "Album" should be bracked by [] so I tried that also.

Let me make sure that I'm in the correct format/window.

I start by opening the report, then I select the "Design View" option, then I
select the "Code" button. Then I paste the syntax that you stated
(see below). I placed that in the "(General)" and "(Declarations)" page
of MicroSoft Visual Basic.

I'm sure that I've made this more difficult than
necessary but it seems to be kicking my butt.
All I want to do is turn the darn letters red for that particular record

Option Compare Database

If Me.[iTunes Selection?] = No Then
Me.[Album].BackColor = 255 'Red
Me.[Year].BackColor = 255
Me.[Format].BackColor = 255
Else
Me.[Album].BackColor = 16777215 'White
Me.[Year].BackColor = 16777215
Me.[Format].BackColor = 16777215
End If


The Declarations area of a module is for declaring module
level variables, not for executable statements.

The code needs to go in the Format event procedure of the
section containing the text box's you're trying to
manipulate, probaly the Detail section.
 
Yes, that means you still have it messed up ;-)

You can easily get to the Format event procedure
(automatically creating the Dub/End Sub statements if
needed), by first clicking in any blank area or the little
separator bar of the detail section, then viewing the
section's property sheet. Once you can see the property
sheet titled Section: Detail, select the Event tab and then
clicking on the little [...] button in the right margin of
the OnFormat property.

That should take you to the report's code module with the
cursor in the right place to put your code between the
Private Sub Detail_Format( . . .
and the
End Sub
lines.

Double check the OnFormat property to make sure it contains
[Event Procedure]

After all the fooling around you've done, it would be a good
idea to view the entire module and make sure you haven't
left any junk laying around. After you think it's ready to
go, use the menu item Debug - Compile <your project> to
check for syntax errors, misspelled names and other errors.
Only after the compile completes without complaint, should
you attempt to open the report to see what happens.
--
Marsh
MVP [MS Access]


Chief said:
I changed the dropdown menu from (General) to "Detail" and I when I
attempted to open the report I recieved the following msg: "The expression On
Format you entered as teh event property setting produced teh follwoing
error: Invalid Outside Procedure.

Does this mean anything to you?
Chief said:
I've been fighting with this code for a while and still have not got it to
work
I double checked the field names and they are correct. I thought that maybe
that "Album" should be bracked by [] so I tried that also.

Let me make sure that I'm in the correct format/window.

I start by opening the report, then I select the "Design View" option, then I
select the "Code" button. Then I paste the syntax that you stated
(see below). I placed that in the "(General)" and "(Declarations)" page
of MicroSoft Visual Basic.

I'm sure that I've made this more difficult than
necessary but it seems to be kicking my butt.
All I want to do is turn the darn letters red for that particular record

Option Compare Database

If Me.[iTunes Selection?] = No Then
Me.[Album].BackColor = 255 'Red
Me.[Year].BackColor = 255
Me.[Format].BackColor = 255
Else
Me.[Album].BackColor = 16777215 'White
Me.[Year].BackColor = 16777215
Me.[Format].BackColor = 16777215
End If
Marshall Barton said:
The Declarations area of a module is for declaring module
level variables, not for executable statements.

The code needs to go in the Format event procedure of the
section containing the text box's you're trying to
manipulate, probaly the Detail section.
 
Marshall/Ofer,

I finally got it working! Don't exactly know what I did, I followed your
advice but had to do some monkeying around. I changed to "backcolor" to
"forecolor" because I wanted the text to change color. I had swithed this
several times throughout this little ordeal with no results. I really
appreaciate your assistance and help with this.

Terry

Marshall Barton said:
Yes, that means you still have it messed up ;-)

You can easily get to the Format event procedure
(automatically creating the Dub/End Sub statements if
needed), by first clicking in any blank area or the little
separator bar of the detail section, then viewing the
section's property sheet. Once you can see the property
sheet titled Section: Detail, select the Event tab and then
clicking on the little [...] button in the right margin of
the OnFormat property.

That should take you to the report's code module with the
cursor in the right place to put your code between the
Private Sub Detail_Format( . . .
and the
End Sub
lines.

Double check the OnFormat property to make sure it contains
[Event Procedure]

After all the fooling around you've done, it would be a good
idea to view the entire module and make sure you haven't
left any junk laying around. After you think it's ready to
go, use the menu item Debug - Compile <your project> to
check for syntax errors, misspelled names and other errors.
Only after the compile completes without complaint, should
you attempt to open the report to see what happens.
--
Marsh
MVP [MS Access]


Chief said:
I changed the dropdown menu from (General) to "Detail" and I when I
attempted to open the report I recieved the following msg: "The expression On
Format you entered as teh event property setting produced teh follwoing
error: Invalid Outside Procedure.

Does this mean anything to you?
Chief THK wrote:
I've been fighting with this code for a while and still have not got it to
work
I double checked the field names and they are correct. I thought that maybe
that "Album" should be bracked by [] so I tried that also.

Let me make sure that I'm in the correct format/window.

I start by opening the report, then I select the "Design View" option, then I
select the "Code" button. Then I paste the syntax that you stated
(see below). I placed that in the "(General)" and "(Declarations)" page
of MicroSoft Visual Basic.

I'm sure that I've made this more difficult than
necessary but it seems to be kicking my butt.
All I want to do is turn the darn letters red for that particular record

Option Compare Database

If Me.[iTunes Selection?] = No Then
Me.[Album].BackColor = 255 'Red
Me.[Year].BackColor = 255
Me.[Format].BackColor = 255
Else
Me.[Album].BackColor = 16777215 'White
Me.[Year].BackColor = 16777215
Me.[Format].BackColor = 16777215
End If
Marshall Barton said:
The Declarations area of a module is for declaring module
level variables, not for executable statements.

The code needs to go in the Format event procedure of the
section containing the text box's you're trying to
manipulate, probaly the Detail section.
 
Back
Top