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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF statement

Status
Not open for further replies.

Sadukar

Technical User
Feb 19, 2003
159
IE
Hi all,

Need a bit of help in vb code.

I want to change the colour of a particular date field to red in a record if it is over todays date. I want this to happen automatically when I open the form.

What code do I use and what do attach it to?
Should it be attached to the button that opens the form?

Thanks
S.
 
If it is in a form then you can use the Form ACTIVATE event

The code you can use is:

If tbDatefield.value > int(datevalue(now())) then
tbdatefield.forecolor = RGB(255,0,0)
else
tbdatefield.forecolour = RGB(0,0,0)
end if

where tbdatefield is the name of your textbox that holds the date

But this will depend on how the date is populated in the 1st place Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 

It dosnt work.
It works but the code for changing the color does nothing.

I am doing it through a subform in Access97. I am not sure if I can change the font value of one cell in access 97.
I cant even do it manually through the table.

Can it be done in 2000?

thanks
s.
 
Cell......Access doesn't have a Cell object.....
The code I provided works on the date in a TEXTBOX on a form
NOT on a table. If you have a table as a subform within a form, where you want to show certain dates in red, I would suggest you try some of the Access forums here - specifically Microsoft: Access Forms Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top