473,569 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filter Query with Date Range

2 New Member
Hello!

I have only been using Access for 24 hours and need some help!!

I have a Query that has totalled the number of unique Projects allocated to my group. This is good!

Now, this total, I need to maintain it - but then also break it down into when the Projects were allocated per month.

What I've done is copied the Grand Total column and pasted it 12 times to the right of the total colum and changed the Caption to Jan through Dec.

Now, what I need and where I'm getting stumped is - the date range Expression to put into Access so that I can isolate for each month - what was allocated when.

The Query will be used in 2 ways - one to give an overall group view of the number of projects allocated out for the year and then broken to each month - so that we can assess Resource Allocations and then used again for the individual Project Manager to see what their total is for the year and then each month.

I would think that this should be super-simple but I'm at a loss... The databse already knows when each of the projects has been or is set to Kick-Off but for the life of me, I can't seem to get the query to break it down into each month's data.

Help! Thanks!
Mar 28 '10 #1
3 5311
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. A problem which often comes up if you don't know a lot about database design is that you can come up with what appears a reasonable approach based on what you would do in a spreadsheet - like creating separate side-by-side fields for monthly totals, or fields for grand totals. You should rarely be storing any calculated field at all, but doing so is not the concern here.

Access, like all relational databases, is not intended to handle repeating field groups within a record. Your side-by-side month date totals are a repeating group. Their inclusion violates the first normal form of database design. Month totals can be calculated when needed from the individual item dates - dates which are only stored once. Presentation of the fields in an Excel-like table with Jan, Feb, Mar etc side by side can be done using a Crosstab query, but the data is not stored in this format at all.

Rather than try to calculate month totals which, unfortunately, are based on flawed designs of your tables, I would strongly advise you to modify your tables now. We have an article on database normalisation and table structures which outlines the basic principles involved. It is essential that you follow such principles or you will never harness the power of a relational database such as Access.

I'm sorry that I can't really advise how you could use your existing totals. In my opinion you will find it much more effective in the medium to long term to revise your design now before it becomes too complex to do so!

Regarding breaking down number of projects into monthly totals, if you have a project date stored for each project you can use functions such as Year and Month on your project date in an Access query to provide you with the year and month for the project. You can then use grouping and totalling or a crosstab in your query to provide you with monthly totals.

There are examples provided in databases such as the Northwind sample which is shipped with Access.

Welcome to Bytes!

-Stewart
Mar 30 '10 #2
NewbieAccessor
2 New Member
Hi Stewart!

Thanks for the response! I'm actually just creating queries and then reports from those queries from an existing database that has been set-up by our global is department. I'm just trying to figure out how to pull the data out.

What I already have is a query to the database that pulls out all the projects that our group has worked on. The project data already has the date info that I require. I have then built a report that takes the query and displays it in a nice way that is easier to read than Excel like cells, rows and columns.

The report is already grouping the projects by the coordinator and it is already calculating the timeframe from the Kick-Off to the Completion dates - as entered in the database and being brought into the query and then to the report.

I started to build a new query whereby I could calculate the total projects - which I was able to do in a couple minutes and is correctly giving the same number as the initial query total records.

I was hoping that I could then create a query that would do double-duty - as a total and month breakout that I could then drop into a report for an overview report of the entire group - and then using the same query as a sub-query to the report that would calculate the total per coordinator and their individual projects assigned and completed.

If I need to create multiple queries then I will but I have even tried taking the query that gives me the correct total number of projects and then in the Criteria, I've tried building numerous expressions like: "InitialDat e = between 1/1/10 and 1/31/10" or >=1/1/10 and <=1/31/10... etc. I just cannot even get one filter, sort or criteria expression to work... I'm also referencing a manual I bought and tried everything that I could see in it, even using IF or WHERE to no avail...

It just seems really odd that it would be so difficult to figure out a simple calculation based on a date range!

Help!
Mar 30 '10 #3
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. Date/Time values are not stored as text but as numbers with whole-number components (for the date) and decimal fractional parts (for the time). If you want to use a date range in an expression you need to tell Access that the date literal is a date and not some text. You do this by enclosing your dates with the pound character '#', indicating that the text within is a date literal.

Using one of your examples a possible criterion in your query would be:

Expand|Select|Wrap|Line Numbers
  1. between #1/1/10# and #1/31/10#
You could also use calculated fields referring to the year and month as I mentioned. This can be done in many different ways, including the use of date formatting to generate a year and month text string which you can then GROUP BY in your query. In SQL syntax the Format version of doing so could be:

Expand|Select|Wrap|Line Numbers
  1. SELECT ..., Format(InitialDate, "YYYY-MM") as YearMonth, ... FROM ...
-Stewart

PS if you want to group your query by month or year you must remove instances of the specific project dates from the query (except where these are inputs to a summarising function such as Year, Month, Format etc). If you retain even one InitialDate field you will be unable to group the query into months as the specific dates concerned will be the highest level at which the query can operate. This also applies to any other field which identifies a specific project - a project ID for instance.
Mar 31 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
18204
by: arthur-e | last post by:
I can filter a query for a report on a field of a subform BUT now.... I'd like to be able to select more than one item in a multi-list box to select all the records. ALSO to use two fields (or more) fields to filter a query based on selections in two or more fields: All the records with NAME = all the names selected in a list box...
11
6082
by: Bob | last post by:
I am in the process of upgrading an Access database to SQL Server (and climbing that learning curve!). The wizard happily upgraded all the tables and I can link to them OK using ODBC. The application controls allocation of revisions to aircraft maintenance manuals for an airline type operation. In the application there is a form loaded...
1
16372
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used VBA to create SQL statements, then apply them. Now that I have been using Access/VBA for awhile, I am wondering if there is a simpler way to do...
0
1750
by: Stinky Pete | last post by:
Hi, The db I'm trying to update has a report form from which all other statistical forms and reports are selected/printed by dept, type, cost, number etc. The report form uses a date filter to generate the necessary data and you can also addtionally filter by by individual department/s, supplier/s if you so wish which is great However,...
6
8352
by: fonzie | last post by:
Is there any way to include two unbound text boxes (for a start date and end date) to a filter-by-form? The users may want to filter by several different fields and they may want to include a date range search on the one date field. Instead of having the users type in
5
2646
by: Ron S | last post by:
After days of searching I finally an example that would work with my application, the only problem is after entering all of the code it is not working. Would someone be kind enough to take a look at this... Exmaple web site: http://allenbrowne.com/ser-62.html My Code: 'Purpose: This module illustrates how to create a search form, _ ...
9
6086
by: dee | last post by:
I'd like to filter by the following criteria: left(LeadDisposition,3) = "Sit" AND Appt_Date = Text767 I have no idea how to do this. Appreciate help.
1
9520
by: jon everly | last post by:
I have Excel 2003 and am using the Microsft Query function to pull in data via SQL from a database. However, I want to set a filter on the data that only pulls in dates between Today and 14 days ago. Query does not recognize NOW() or TODAY(). I do I write the SQL statement to only pull data within a given date range (Today and 14 days ago)? ...
1
5614
by: Cara Murphy | last post by:
Hi There! Hoping you are able to help me with a filtering scenario: I have created a pop up form (Filter) to filter a report (Open Issues), which currently has a number of combo boxes which apply the filters to the fields in the report. I would like to use this form to filter the report within a date range (Raised Date From and Raised...
4
2845
Sandboxer
by: Sandboxer | last post by:
I want to be able to program Access to provide for me, by individual day, what my contract obligations are to my customers. Will Access recognize all the individual days in between a date range (simply a "from" date and a "to" date)? Additionally, I need to delivery a specific quantity of product when the customer's inventory is within about...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.