Using Date() as a condition

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!
 
K

Ken Snell \(MVP\)

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\#")
 
C

Chad Landry

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top