SteveL13
asked on
How count number of days represented in detail section of report
I have a report that shows records of parts produced in a date range. But in the detail section of the report I need to show the number of distinct days represented. In other words if the report shows records produced on Friday, August 19th and records produced on Monday, August 22nd and records produced on Monday, August 23rd... then the answer should be 3.
What would the syntax be for the control source of this field?
--Steve
What would the syntax be for the control source of this field?
--Steve
e.g. DateDiff("d",#01/01/2011#, #01/02/201 1#)
ASKER
That won't work. Remember, the report shows records that have dates listed like:
Record #1 8/19/2011 blah, blah, blah
Record #1 8/22/2011 blah, blah, blah
Record #1 8/23/2011 blah, blah, blah
So the answer has to be 3 but I don't know how to code it.
Record #1 8/19/2011 blah, blah, blah
Record #1 8/22/2011 blah, blah, blah
Record #1 8/23/2011 blah, blah, blah
So the answer has to be 3 but I don't know how to code it.
if you have multiple records showing multiple dates of Aug 19, Aug 22, Aug 23
you will need something like this to have a distinct count of days
select count(*) from (select distinct [datefield] from tableName)
need more info about the records from table
upload a copy of db if you have trouble figuring out to display the count of unique days
you will need something like this to have a distinct count of days
select count(*) from (select distinct [datefield] from tableName)
need more info about the records from table
upload a copy of db if you have trouble figuring out to display the count of unique days
for the sample you posted , try the dcount() function
or you can use vba codes using recordset in the format or print event of the detail section of the report
ASKER
There ARE multiple records showing dates in the detail section of the report. But I need to show the number of distinct dates in the footer section of the report. The grouping on the report is based on a field named "Molder". The query under the report is named "qryDailyProdByMoldSec" if that helps.
So something like...
= count(*) from (select distinct [date] from qryDailyProdByMoldSec) where [Molder]= [txtMolder] or something like that maybe?
So something like...
= count(*) from (select distinct [date] from qryDailyProdByMoldSec) where [Molder]= [txtMolder] or something like that maybe?
ASKER
So in the onprint event of the footer section maybe something like this?
Me.txtDayCount = DCount("Date", "report detail section here", "Molder = me.txtMolder")
???
--Steve
Me.txtDayCount = DCount("Date", "report detail section here", "Molder = me.txtMolder")
???
--Steve
Me.txtDayCount = DCount("[Date]", "qryDailyProdByMoldSec", "Molder =" & me.txtMolder)
Got this to work:
=eCount("Date","qryDailyPr odByMoldSe c","molder = '" & [molder] & "'",True)
Using this guys ecount udf:
http://allenbrowne.com/ser-66.html
=eCount("Date","qryDailyPr
Using this guys ecount udf:
http://allenbrowne.com/ser-66.html
ASKER
I tried...
=eCount("Date","qryDailyPr odByMoldSe c","molder = '" & [molder] & "'",True)
Using this guys ecount udf:
http://allenbrowne.com/ser-66.html
But I get an error message (twice) that reads: Ecount Error 3061. Too few parameters. Expected 2.
=eCount("Date","qryDailyPr
Using this guys ecount udf:
http://allenbrowne.com/ser-66.html
But I get an error message (twice) that reads: Ecount Error 3061. Too few parameters. Expected 2.
The value in square brackets is grouped value control on the form in my sample, maybe it should be txtMolder for you?
=eCount("Date","qryDailyPr odByMoldSe c","molder = '" & [txtMolder] & "'",True)
=eCount("Date","qryDailyPr
ASKER
ASKER
To c1nmo... I did try
=eCount("Date","qryDailyPr odByMoldSe c","molder = '" & [txtMolder] & "'",True)
and received the same error twice.
=eCount("Date","qryDailyPr
and received the same error twice.
ASKER
I can see that your example does work but for whatever reason I can't get it to work.
=eCount("Date","qryDailyPr odByMoldSe c","molder = '" & [Molder] & "'",True)
Its almost like I need to replace qryDailyProdByMoldSec with the detail section of the report.
=eCount("Date","qryDailyPr
Its almost like I need to replace qryDailyProdByMoldSec with the detail section of the report.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ASKER
Ok, I was able to get this to work by adding the txtMolder field to the detail section of the report.
Me.txtDayCount = DCount("[Date]", "qryDailyProdByMoldSec", "Molder ='" & me.txtMolder & "'")
But what I need is the number of unique dates, not the total date count. So if the detail section shows...
Record #1 8/19/2011 blah, blah, blah
Record #2 8/22/2011 blah, blah, blah
Record #3 8/23/2011 blah, blah, blah
Record #4 8/19/2011 blah, blah, blah
Record #5 8/23/2011 blah, blah, blah
then the result should be 3. Not 5.
Me.txtDayCount = DCount("[Date]", "qryDailyProdByMoldSec", "Molder ='" & me.txtMolder & "'")
But what I need is the number of unique dates, not the total date count. So if the detail section shows...
Record #1 8/19/2011 blah, blah, blah
Record #2 8/22/2011 blah, blah, blah
Record #3 8/23/2011 blah, blah, blah
Record #4 8/19/2011 blah, blah, blah
Record #5 8/23/2011 blah, blah, blah
then the result should be 3. Not 5.
I even tried changing my sample renaming mydate to date in case it was a keyword problem but it still works.
Are you getting an error or just no output?
Are you getting an error or just no output?
ASKER
c1nmo... getting an error
ref 36478435, can you not use eCount at this stage
upload a copy of the db...