If between dates, change colour

The Bey

Registered User.
Local time
Today, 15:02
Joined
Jun 21, 2011
Messages
84
I'm having a report run from a query, and I'm wondering if I can change the backing colour of certain dates on my report via its code.

eg. If Date is between Date() and DateAdd("m", 6, Date())
Me.FieldDate.BackColour = Red

I'd like to do it in code because the query is already asking for criteria from a form
 
Right click on the control and choose Conditional Formatting.

Change the condition to Expression Is and enter this:

Code:
[fieldname] >= Date() And [fieldname] <= DateAdd("m", 6, Date())

Set the colours as required
 
Thanks for the quick response.

Well it didn't want to work :( The expression I used is

"[InsActionDueDate]>=Date() And [InsActionDueDate]<=DateAdd("m",12,Date())"

where InsActionDueDate is the fields from the query. Is this right, or should I use the column title?
 
Here's a snapshot of what I've done because it also shows my fields and things. I'm not very good at explaining things so this makes it easier
 

Attachments

  • Example.JPG
    Example.JPG
    65.6 KB · Views: 115
  • Example 2.JPG
    Example 2.JPG
    42.7 KB · Views: 125
Should work with either the fieldname in the RecordSource query or the Control Name.

Is your date field just text or a DateTime datatype field?
 
Um it's formatted to General Date and in the field it will only ever have "##/##/####", so only date, no time.
 
Are you sure it isn't working? Everything seems to be correct.

Can you post a cut down version of the database with just the essential objects and some dummy records?
Compact the database and zip it before posting.
 
Here. A lot of the data has been removed, but the records needed are still present
 

Attachments

Unfortunately I don't have a lot of experience with Reports. These same settings in a Form would definitely work fine.

I did notice that in the Report View, the Conditional Format background color is honoured when the control of a conforming record is clicked on. There must be another thing we need to know. I tried removing the Alternate Back Color but that made no difference.

Sorry I can't get to the bottom of the problem.
 

Users who are viewing this thread

Back
Top Bottom