Using Date() as a condition

  • Thread starter Thread starter Chad Landry
  • Start date Start date
C

Chad Landry

I have the following condition, which compares one date field with the
current date:

[Forms]![Performance_Form]![Milestone_Due_Dates_Subform].[Form]![100pctloan_Const_date_Due]<Date()

The idea is that if the due date is less than today's date it will set the
backcolor value of a control to red. But, for some reason the macro just
sets the backcolor to red regardless of the date!

Does anyone have any ideas?

Thanks!
 
If the form's [100pctloan_Const_date_Dur] control is not formatted as a Date
(e.g., the control's Format property is set to Short Date or some other
variation), then ACCESS / Jet sometimes will not recognize that you have a
date value in that control.

Try this:

CDate([Forms]![Performance_Form]![Milestone_Due_Dates_Subform].[Form]![100pctloan_Const_date_Due])<Date()

or this:

Format([Forms]![Performance_Form]![Milestone_Due_Dates_Subform].[Form]![100pctloan_Const_date_Due],"\#mm\/dd\/yyyy\#")<Date()

or this:

Date()>=Format([Forms]![Performance_Form]![Milestone_Due_Dates_Subform].[Form]![100pctloan_Const_date_Due],"\#mm\/dd\/yyyy\#")
 
Thanks! That worked great.

Ken Snell (MVP) said:
If the form's [100pctloan_Const_date_Dur] control is not formatted as a Date
(e.g., the control's Format property is set to Short Date or some other
variation), then ACCESS / Jet sometimes will not recognize that you have a
date value in that control.

Try this:

CDate([Forms]![Performance_Form]![Milestone_Due_Dates_Subform].[Form]![100pctloan_Const_date_Due])<Date()

or this:

Format([Forms]![Performance_Form]![Milestone_Due_Dates_Subform].[Form]![100pctloan_Const_date_Due],"\#mm\/dd\/yyyy\#")<Date()

or this:

Date()>=Format([Forms]![Performance_Form]![Milestone_Due_Dates_Subform].[Form]![100pctloan_Const_date_Due],"\#mm\/dd\/yyyy\#")


--

Ken Snell
<MS ACCESS MVP>


Chad Landry said:
I have the following condition, which compares one date field with the
current date:

[Forms]![Performance_Form]![Milestone_Due_Dates_Subform].[Form]![100pctloan_Const_date_Due]<Date()

The idea is that if the due date is less than today's date it will set the
backcolor value of a control to red. But, for some reason the macro just
sets the backcolor to red regardless of the date!

Does anyone have any ideas?

Thanks!
 
Back
Top