Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CF Expression Help

Status
Not open for further replies.

xmeb

Technical User
Jun 5, 2013
89
Hi:

I have searched on Google for what I want to do but I have found nothing that is exactly the same so far.

On a report I have a subreport that has a "PrimiaryLocation" text box. I use the following in the subreport query criteria for my field "DDate" to show primary locations for the last five days which works fine.


Code:
>=DateAdd("d",-1,Date())-5

What I would like to do using CF is to have primary locations that match todays date be a different color and those that are two days old be a different color.

Thanks,

xmeb
 
I'm not sure why you can't spell out "conditional formatting" at least once so everyone understands what you are referencing in your question. It isn't until your last sentence that it becomes somewhat clear ;-)

What have you tried? Did you use "Expression Is"?

Duane
Hook'D on Access
MS Access MVP
 
Sorry, I will write it out next time.

I have tried to use "Expression Is" but I do not know how to write the expression. I tried ones like the following but they do not work.

Code:
DDate > Now()

Thanks.
 
I would make sure the Expression Is contains [DDate]>Now() with the []s around the field name. Also the text box background can't be transparent if you expect the background colors to display.

Duane
Hook'D on Access
MS Access MVP
 
Still does not work. Thanks.
 
I tested a "field value is equal to" expression on the same text box in the same subreport and it worked fine. There is a text box bound to "DDate" in the subreport. Thanks.
 
What do you mean by future dates?
 
No and I put in a date for next month but it still does not work. Thanks.
 
Still not working. I have conditional formatting on a number field in the same subreport and it works fine. Thanks.
 
I don't understand why conditional formatting isn't working. Is the control actually a text box?

As an alternative try use code in the On Format event of the section of the subreport containing the controls like:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If Me.DDate > Now() Then
        Me.PrimaryLocation.BackColor = vbYellow
     Else
        Me.PrimaryLocation.BackColor = vbWhite
    End If
End Sub

Duane
Hook'D on Access
MS Access MVP
 
It is a text box and that does not work either. It must be something to do with the "Now()" because other conditional formatting works fine on the same text box in the same subreport. Thanks.
 
Date does not work either. I must have built something wrong. I will keep working on it and let you know if I figure it out. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top