Expression Too Difficult to Calculate? Tried everything...

  • Thread starter Thread starter michael c
  • Start date Start date
M

michael c

I have a contracts query with a calculated field, EndDate,
that is calculated as follows:

EndDate: DateAdd('yyyy',[TermYears],DateAdd('y',-1,
[StartDate]))

It basically adds the term years minus one day to the
StartDate. This works find. The problem is when I try to
run a report and filter the report by showing only those
EndDates that are greater than today. I tried both of the
following:

Private Sub Report_Open(Cancel As Integer)
DoCmd.ApplyFilter , "[EndDate] >= Date()"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.ApplyFilter , "DateAdd('yyyy',[TermYears],DateAdd
('y',-1,[StartDate]))>Date()"
End Sub

I'm getting an error that says the expression is typed
incorrectly or is too complex to be evaluated. Any
suggestions would be great! I'm mystified by this one.
Thanks!!
 
It basically adds the term years minus one day to the
StartDate. This works find. The problem is when I try to
run a report and filter the report by showing only those
EndDates that are greater than today. I tried both of the
following:

Private Sub Report_Open(Cancel As Integer)
DoCmd.ApplyFilter , "[EndDate] >= Date()"
End Sub

It's interpreting Date as a division expression - 11 divided by 19
divided by 2003. Use the syntactically required # delimiter:

DoCmd.ApplyFilter, "[EndDate] = #" & Date() & "#"
 
Back
Top