Expression Too Difficult to Calculate? Tried everything...

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

John Vinson

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() & "#"
 

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