Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 11th, 2007, 06:24 PM
Registered User
Join Date: Oct 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filter on Certain dates

Hello... this is my first post and I have an Access formula dilema that I've been struggling for several days now.

I have 2 separate date fields on a Monthly Status Report I created and don't know how to create the formula on the Report's Filter property.

One is called Effective_Date and the other one is called Expiry_Date.

I am trying to capture the following records with these scenarios

(a) Records where the Effective_Date is Oct-2007 OR
(b) Records where the Expiry_Date is Oct-2007 OR
(c) Records that would fall between Effective_Date and Expiry_Date in Oct-2007 (such as Aug-2007 to Nov-2007)

Any help is very much appreciated!!!

Old October 12th, 2007, 12:28 AM
Friend of Wrox
Join Date: Jul 2005
Location: Oklahoma City, OK, USA.
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts

For (a) nd (b)

Where Effective_Date between #10/1/2007# and #10/31/2007# or Expiry_Date between #10/1/2007# and #10/31/2007#

Note sure what you mean for (c)

"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.
Old October 12th, 2007, 08:32 AM
Registered User
Join Date: Oct 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Hopefully this will clarify what I need. I do a monthly report and each marketing message is a separate record having StartDate and EndDate fields. I need to filter records where messages started, ended and are still in market within Oct-2007.

For the messages that Started or Ended in Oct-2007 I'm using.
[StartDate]="10-2007" or [EndDate]="10-2007"

My dilemma for scenario (c) is how to identify those records that may fall between The Start and End Date. In other words, if a marketing message Start Date is before Oct-2007 and the End date is after Oct-2007 I want to also keep that record. (Example: StartDate=July-2007 and EndDate=Dec-2007).

When I tried to enter it this way in the Report's Filter I kept getting a syntax error.
[StartDate]<"10-2007" and [EndDate]>"10-2007"

is there another way to rephrase this?

Old October 15th, 2007, 08:10 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG

Hello, Diana. The date ranges you are trying to set are not valid dates. A date (in USA format) is defined by a month, day, and year (usually expressed mm/dd/yyyy).

You said "Oct-2007". That is not a date. First, you have it in quotes which make it a string. Second, you only have a month and year but no day. Valid date ranges (in USA format) are, for example:

[StartDate] Between #10/1/2007# And #10/31/2007#
[StartDate] < #10/1/2007# and [EndDate] > #10/31/2007#

The pound sign # is the delimiter for the DATE data type.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Old October 15th, 2007, 01:17 PM
Registered User
Join Date: Oct 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Hello... I figured out what I did wrong. I had the variable setup as a date field (ie #10/1/2007#, which I later formatted it using the Date Part function so that the date would be "10-2007". Although my start and end fields were valid dates, it seems MS Access doesn't calculate properly when you've formatted the dates using date part. I redid my formula using the original date (#10/1/2007#) instead of "10-2007" and it now works.

Thanks to all who helped me with this!!

Old October 22nd, 2007, 09:56 AM
Authorized User
Join Date: May 2007
Location: , , .
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts

minor alteration to what you've put in the data fields, try making the two dates 30/09/2007 and 01/11/2007 and that way ensure that you are catching the data that expires on the 31st october and starts on the 1st october as i've learnt access doesn't quite work right with dates even when you use the >= or =< and the relevant dates.

Similar Threads
Thread Thread Starter Forum Replies Last Post
BindingSource.Filter bufanator Visual Basic 2005 Basics 2 May 23rd, 2007 10:16 AM
filter a sub form ahying Access VBA 1 June 29th, 2006 04:27 AM
Filter Help mcloum Classic ASP Databases 2 November 10th, 2005 05:40 PM
Filter Help mcloum BOOK: Beginning ASP 3.0 1 August 26th, 2005 03:10 PM
How to filter data? coolest_pie SQL Server 2000 7 May 7th, 2004 07:00 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.