Conditional Formatting

J

joseph

I fould a post in which it was explained how to force backround colors based
on certain "text" conditions ... it went as follows:

Select Case Me.coname
Case "x"
Me.coname.BackColor = vbRed
Case "y"
Me.coname.BackColor = Rgb(220,220,255) 'lt blue
Case "z"
Me.coname.BackColor = vbBlue
. . .
Case Else
Me.coname.BackColor = vbWhite
End Select

.... however, my situation is a little unique and definately more involved ...

I have a report that lists the following fields: Date of Authentication,
Date of Appointment, Last Name, First Name, M.I., Office Appointed To,
Cofirmation Date, Date Oath Received.

My first color is when the oath received date is greater than 30 days from
the authentication date ... color = red

Next, If Date Oath Received is null, color = yellow

Will these be if then statements in VBA? if so, what would the code be?

I know that I will select the detail section; format event, build code to
open the VBA, but then what?
 
D

Duane Hookom

I would create a small user-defined function that accepts some of your fields
as arguments and then returns a color value. Place the function in a module
named "modBusinessCalcs". It might look like:

Public Function GetBGColor(datAuth as Date, datAppt as Date, ...) as Long
' code goes here
End

Then in the On Format event of your report section, you could call this
function like:
Me.coName.BackColor = GetBGColor(Me.txtAuthDate, Me.txtApptDate,...)
 
J

joseph

Thank you Duane,

I actually couldn't find my original post and inadvertantly reposted (but
with additional info) ... anyway ...

there were alot of holes that required me to fill and I took a stab and
nothing ... if you don't mind, take a look at my post for today, same title
"Conditional Formatting"

Joseph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top