473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Filtering an access report which has an aggregate query as record source

I have a table with following fields
- SDate
- TestCount

Now, the values in the sdate are typically like 01/01/2012 06:45 PM,01/02/2012 06:45 PM,01/01/2012 07:45 PM,10/10/2012 06:45 PM,11/30/2012 07:45 PM,

Now, I want to create a report which shows data group by the "Time" value under the 'sdate' field and shows the sum of "test count" time wise

So my query is

Expand|Select|Wrap|Line Numbers
  1. Select Timevalue(Sdate) , 
  2. sum(TestCount) 
  3. from TestMaster
  4. Group by Timevalue(Sdate)
I am using this query as recordsource in the report.

This works fine..If I call the report from a form , the report is generated correctly..

Now, the problem is while calling the report from the form, I want the report to display data for a specific date range only. So I have two fields called startDate and EndDate on the form.
I am passing these two as parameters while calling the report
Expand|Select|Wrap|Line Numbers
  1. docmd.openreport "reportName", acfilterview,,"Datevalue(sdate)>='" & startdate & "' And datevalue(sdate)<='" & endDate & "'"
now, this is not working for me, I figured out the reason as the original query is having aggregate fields only, and passing paramter are non-aggregate, thsi is not working. Can anyone please help me on this?
Dec 21 '12 #1
3 2643
MikeTheBike
639 Expert 512MB
Hi

I think you need to delimit and format the date like this
Expand|Select|Wrap|Line Numbers
  1. DoCmd.openreport "reportName",,,"Datevalue(sdate)>=#" & format(startdate,mm/dd/y") & "# And datevalue(sdate)<=#" & format(endDate,"mm/dd/yy") & "#"
the dates need formating as a string (US or Universal format) and delimiting with a #.

This is asssuming that startdate and enddate are actualy dates. If they are stings, that are formated correctly and have the # delimiters included, then you do not need the apostrophe delimiter (apostrophes are required for sting fields only).

HTH


MTB
Dec 21 '12 #2
Rabbit
12,516 Expert Mod 8TB
You said:
I figured out the reason as the original query is having aggregate fields only, and passing paramter are non-aggregate, thsi is not working.
That is wrong. There is no such thing as a parameter that is an aggregate or non-aggregate. The reason it's not working is the result has no field called SDate.

You need to filter the underlying detail data that is passed to the aggregate query.
Dec 21 '12 #3
NeoPa
32,556 Expert Mod 16PB
Rabbit:
That is wrong
While technically correct, I believe the original statement, although not expressed in perfect English, reflects a correct understanding of the issue, if not a full grasp of it exactly. Certainly the fundamental problem.

Let me see if I can explain so all see the point (I'm sure Rabbit will immediately but it may be harder to explain generally.) :

The [SDate] field (which is a TimeStamp rather than Date field) is not included in the aggregated output of the query. It would have to go, logically, at the WHERE point of the aggregate query (IE. Before any aggregation.) and this is not possible from the report call as that can only filter the results of the query, which is essentially equivalent to putting it in at the HAVING point, which is after the aggregation.

Bearing in mind the [SDate] field consists of both Date and Time, I believe the solution is to design a non-aggregated query to support the report, which itself should aggregate the data. To filter the Date data correctly, it must be remembered that the time is included. IE. If a date range is provided as :
Expand|Select|Wrap|Line Numbers
  1. ([SDate] Between #01/01/2013# And #01/05/2013#)
then the designer should understand that DateTimes on the 5th January 2013 will not be included.
Dec 21 '12 #4

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

Similar topics

1
by: Justin Koivisto | last post by:
I am trying to create a report that displays a name of an advertising source and count of the number of times it was hit between certain date ranges. The data is split between two different...
3
by: Clare | last post by:
Hi I have a report that is made of 4 subreports. There is no actual information in the main report, and the record source is empty. In the Header section of the main report, I have a text box...
3
by: eddiec | last post by:
hi everyone, I have a report in an adp that uses aggregate functions in its record source and I am trying to figure out how to filter the records displayed in the report: DoCmd.OpenReport...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
2
by: Bob | last post by:
I've got a bound report with a query as the record source. I'm adding a total to the footer and have inserted a text box to display it. I'm attempting to set the control source of the text box to...
1
by: solar | last post by:
Can i define the record source of the report in the command line opening the report ? I know how to place the record source in the OnOpen event of the report but i do not know is it posible to do...
8
by: nn0410 | last post by:
I have a report whose record source is a query. The query includes an ORDER BY clause that sorts on a particular set of columns. I would like to be able to run the same report with the same input...
1
by: lorirobn | last post by:
Hi, I have a report that displays summary information, summing prices for all records for a RoomID meeting certain criteria, and printing the roomID and sum on a detail line. Now I want to add...
2
by: ccwells | last post by:
Hi, I am a novice to VB, using Access 2003 on a XP-SP2 platform, and I have a small database for tracking expenses, and want to be able to filter my expense report by date. I currently have a...
1
by: jglabas | last post by:
For a report, I am using a query as my record source. The query produces 5 columns by 3272 records. The data in columns 1 & 2 (“Objective” and “Rating”) repeats every 409 records The data for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.