Field Conditional Formating

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

Guest

after looking through this forum i found the code for conditional formatting
and alter it to suit me to the following

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim bgred As Long, bgblack As Long
bgred = RGB(255, 0, 0)
bgblack = RGB(0, 0, 0)

If Me.[3 Mnth Latest].Value < Now() Then
Me.[3 Mnth Latest].BackColor = bgred
Else
Me.[3 Mnth Latest].BackColor = bgblack
End If

End Sub


however when the report opens it does nothing.

i want the 3 mnth latest field to change colour

what am i doing wrong?
 
Hi Rick

thanks for the reply

what you suggested does not work as i want to conditional formatting to be
using the function now()

i tried it but it does not work as it treats it as text

Rick B said:
Why not just use the built in conditional formatting available in the
"format" menu?


--
Rick B



Panagiotis Marantos said:
after looking through this forum i found the code for conditional
formatting
and alter it to suit me to the following

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim bgred As Long, bgblack As Long
bgred = RGB(255, 0, 0)
bgblack = RGB(0, 0, 0)

If Me.[3 Mnth Latest].Value < Now() Then
Me.[3 Mnth Latest].BackColor = bgred
Else
Me.[3 Mnth Latest].BackColor = bgblack
End If

End Sub


however when the report opens it does nothing.

i want the 3 mnth latest field to change colour

what am i doing wrong?
 
I just tried this to double check that there wasn't something that Access
was being picky about. I opened the built-in Conditional Formatting dialog
for the textbox with the report open in design view. I set the "Condition 1"
formatting to

Field Value Is, less than, Now()

and set the color desired. It worked fine. You do need the () in the
statement for it to work.

--
Wayne Morgan
MS Access MVP


Panagiotis Marantos said:
Hi Rick

thanks for the reply

what you suggested does not work as i want to conditional formatting to be
using the function now()

i tried it but it does not work as it treats it as text

Rick B said:
Why not just use the built in conditional formatting available in the
"format" menu?


--
Rick B



"Panagiotis Marantos" <[email protected]>
wrote
in message news:[email protected]...
after looking through this forum i found the code for conditional
formatting
and alter it to suit me to the following

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim bgred As Long, bgblack As Long
bgred = RGB(255, 0, 0)
bgblack = RGB(0, 0, 0)

If Me.[3 Mnth Latest].Value < Now() Then
Me.[3 Mnth Latest].BackColor = bgred
Else
Me.[3 Mnth Latest].BackColor = bgblack
End If

End Sub


however when the report opens it does nothing.

i want the 3 mnth latest field to change colour

what am i doing wrong?
 
I agree with Wayne. I have used similar formatting many times.

Is the field you are comparing to "Now()" a date/time field? You might try
comparing to "Date()" which will use midnight today instead of the current
time.


--
Rick B



Panagiotis Marantos said:
Hi Rick

thanks for the reply

what you suggested does not work as i want to conditional formatting to be
using the function now()

i tried it but it does not work as it treats it as text

Rick B said:
Why not just use the built in conditional formatting available in the
"format" menu?


--
Rick B



"Panagiotis Marantos" <[email protected]>
wrote
in message news:[email protected]...
after looking through this forum i found the code for conditional
formatting
and alter it to suit me to the following

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim bgred As Long, bgblack As Long
bgred = RGB(255, 0, 0)
bgblack = RGB(0, 0, 0)

If Me.[3 Mnth Latest].Value < Now() Then
Me.[3 Mnth Latest].BackColor = bgred
Else
Me.[3 Mnth Latest].BackColor = bgblack
End If

End Sub


however when the report opens it does nothing.

i want the 3 mnth latest field to change colour

what am i doing wrong?
 
Back
Top