Why does my filter not work?

S

Stapes

Hi

I am trying to show just those records due for renewal. Due Date is a
date 6 weeks from now. Date is the date the subscription expires. I am
trying to display all the records due to expire. Here is my code:

Forms.Form1![Subscriber Details].Form.Filter = "((Date < #" & DueDate
& "#))"

It doesn't work, in that it shows Dates after the Due Date. However,
if I set it to Date =, or Date >, it works fine. It just doesn't seem
to recognise the less than operator. Crazy, n'est ce pas.

Stapes
 
D

Douglas J. Steele

Don't know why it works in other cases and not this one, but if your field
really is named "Date", rename it.

Date is a reserved word, and should never be used for your own objects. For
a good discussion on what names to avoid, see what Allen Browne has at
http://www.allenbrowne.com/AppIssueBadWord.html

If you cannot (or will not) rename the field, at least put square brackets
around it:

Forms.Form1![Subscriber Details].Form.Filter = "[Date] < " & _
Format(DueDate, "\#yyyy\-mm\-dd\#")

The use of the Format statement is recommended if there's a chance that the
user's short date format is dd/mm/yyyy.
 
S

Stapes

Don't know why it works in other cases and not this one, but if your field
really is named "Date", rename it.

Date is a reserved word, and should never be used for your own objects. For
a good discussion on what names to avoid, see what Allen Browne has athttp://www.allenbrowne.com/AppIssueBadWord.html

If you cannot (or will not) rename the field, at least put square brackets
around it:

Forms.Form1![Subscriber Details].Form.Filter = "[Date] < " & _
Format(DueDate, "\#yyyy\-mm\-dd\#")

The use of the Format statement is recommended if there's a chance that the
user's short date format is dd/mm/yyyy.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)




I am trying to show just those records due for renewal. Due Date is a
date 6 weeks from now. Date is the date the subscription expires. I am
trying to display all the records due to expire. Here is my code:
Forms.Form1![Subscriber Details].Form.Filter = "((Date < #" & DueDate
& "#))"
It doesn't work, in that it shows Dates after the Due Date. However,
if I set it to Date =, or Date >, it works fine. It just doesn't seem
to recognise the less than operator. Crazy, n'est ce pas.
Stapes- Hide quoted text -

- Show quoted text -

Thank you
 

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