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!

Report field Colur dependent on Date 1

Status
Not open for further replies.

Dilly

Technical User
May 28, 2001
41
GB
I have a report that shows borrowed equipment with the date it is due to be returned. I would like to highlight the records that have to go within the next 30 days. I cannot seem to find the correct code to highlight ones that are due within 30 days or less of todays date.

Please note I am self teaching and finding VBA quite challenging.

 
Dilly,

If you're report has a text box called txtDateDue which contains the date that the item is due to be returned you can use the following code in the OnPrint event of the section detail:-


Dim daysdue As Integer
daysdue = Me![txtDatedue] - Now()
If daysdue > 30 Then
Me!txtDatedue.ForeColor = 255
Else
Me!txtDatedue.ForeColor = 0
End If

This will highlight the date field only of any items that are due within the next 30 days.

If you wish to include more simply add the text box names with .forecolor.

HTH

Steve.
 
Linda,

I've only ever seen conditional formatting in Excel, my version of Access 2000 hasn't got it anyway. Unless I'm missing something.

Cheers,

Steve.
 
Well, even better is to set all of the controls in the section to have their backgrounds transparent and just manipulate the detail backcolor in a similar fashion. Thsi technique is at least as old as access ver 2.x and highlights the whole record in "one fell swoop". It is also possible to individually color code records in a variety of categories in this manner - without much extra code.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top