Issue with filtering report by date

Beansy

Registered User.
Local time
Tomorrow, 06:30
Joined
Dec 19, 2012
Messages
20
Access version: 2013

Hey all

Didn't really know whether to put this one in Report forum or Query forum as it kinda applies to both but is regarding a query for the filter property of a report so put it here :)

This is a fairly weird issue that has had me stumped most of the morning. I have an access report that shows sales to follow up.

The user can click a button on the report that opens a form where they can select various filters. Once the user has selected the filters and clicks done, I have some VB code that fires which builds an SQL string with all of the filters selected. It then reopens the report with the new filter.

What I am running into issues with is one specific filter that the user can select. They can select a "from date" and "to date". Sometimes this filter returns what I want and sometimes it doesn't.

For example. I set 01/01/14 as the start date and end date as 15/01/14. <-- this works as desired.

But if I put start date as 10/12/13 and end date 15/01/14 for example then it returns all previous records up to the specified end date. I.E dates such as 10/10/13 will show. :banghead:

This is the VB code used to build the SQL for this filter:

Code:
newWhere = newWhere & "[FollowUpDate] > #" & Me.txtFromDateSelect & "# AND [FollowUpDate] < #" & Me.txtToDateSelect & "#" & " AND "

note: I have also tried using the between SQL syntax for querying the date to no avail and the same results.

This is the SQL that the above code creates:

Code:
[FollowUpDate] > #1/01/2014# AND [FollowUpDate] < #15/01/2014#

Things I have tried and figured out.

This only happens when I try select a start date prior to 12/12/13 (so the year is not the issue)

This happens both when I apply just the from date and to date filter and also when I mix it in with other filters. I.E Company name, product etc..

Thanks to anyone that can help me!
 
The first link worked great thanks!
 
Happy to help! Hoping to get to your area soon. My daughter moved to Wellington last year. We've visited once so far, but didn't get too far from Wellington. Next trip will definitely include the South Island.
 
Be sure to consider visiting Abel Tasman, Wanaka, and Queenstown if you make it to the South Island. Best places in NZ in my opinion if your looking for a mix of scenery and a tourist feel. I hope you enjoy your visit!
 
I'll keep those in mind, thanks! Wellington was nice but I know the really "wow" parts of NZ are elsewhere. Hopefully the earthquakes weren't too bad for you. I know they really hammered Christchurch.
 
Yea it's been a slow recovery. City center just starting to thrive now. Job prospects for programmers is excellent here haha.
 

Users who are viewing this thread

Back
Top Bottom