Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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!!!

Reply With Quote
  #2 (permalink)  
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
Default

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)

Boyd
"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.
http://www.officeprogramming.com
Reply With Quote
  #3 (permalink)  
Old October 12th, 2007, 08:32 AM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?

Reply With Quote
  #4 (permalink)  
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
Default

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
Reply With Quote
  #5 (permalink)  
Old October 15th, 2007, 01:17 PM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
  #6 (permalink)  
Old October 22nd, 2007, 09:56 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.