By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,655 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,655 IT Pros & Developers. It's quick & easy.

Changing color depending on dates

P: 68

I have a column(End Date) in a form which indicates to the course's end date.
I want the color of the cell of Course ID column change if the system date exceed the end date.

Best regards
Dec 1 '08 #1
Share this Question
Share on Google+
5 Replies

Expert 100+
P: 1,923
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If DateDiff("d", Me.[End Date], Date()) > 0 Then
  3.        Me.[End Date].BackColor = vbRed
  4. End If
  5. End Sub
Dec 1 '08 #2

P: 68
Thanks.But the code works improperly all the cells' colors have been changed .

I want only to change the color of the cells whose their date less than the system date. In other words, if the system date exceed the end date only the cell of the same record should be changed.
Dec 1 '08 #3

P: 675
The suggested solution will work for Single Forms, but not for Continuous Forms, because the format is applied to the form, and then the form is displayed with multiple copies.

For Access 2000 and above, there is a way. Open form in design view, select the field (End Date), and then select Menu Item = Format. This is on the Menu Bar, not the Properties Box. This brings up a dialog which allows conditional formatting of ForeColor, BackColor, Font, and Enabled=True/False.

For this question, choose "Field Value Is", "less than", Date().

See Access Help "Apply or change conditional formatting on a control", as there are some limiting Notes.

Dec 1 '08 #4

Expert 100+
P: 1,287
In Access 2007, you can change the conditional formatting for the Course ID field to expression is and reference another field like "[End Date] < Now()"
Dec 1 '08 #5

P: 68
Thanks for all.

OldBirdman your solution was perfect everything is ok now.

Best Regards
Dec 2 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.