SteveL13
asked on
How count number of times a string of characters appears in the detail section of a report
In the detail section of a report I have a field named "txtDescription". The field's control source is "Description" coming from a query and the query data comes from a table named "txtProjectDetail".
The Description can come from any of the records entered in a table named “tblReprintCodes”.
In the report footer I want to print something like this…
Department #1 count: 12 records
Department #2 count: 6 records
Department #3 count: 0 records
Department #4 count: 9 records
Etc.
The “Department” needs to be some kind of loop that cycles through the available records in “tblReprintCodes”.
How can I accomplish this?
--Steve
The Description can come from any of the records entered in a table named “tblReprintCodes”.
In the report footer I want to print something like this…
Department #1 count: 12 records
Department #2 count: 6 records
Department #3 count: 0 records
Department #4 count: 9 records
Etc.
The “Department” needs to be some kind of loop that cycles through the available records in “tblReprintCodes”.
How can I accomplish this?
--Steve
What if the character string is contained two or more times in a given record - or is that impossible?
ASKER
The character string would never be contained 2 or more time. What I have (below) is working so far but if a "Department" had zero cases I want that department to appear with a "0" count. How do I make that happen in the query?
SELECT tblReprintCodes.Descriptio n, Count(Nz([Description],0)) AS RespDept
FROM tblProjectDetail LEFT JOIN tblReprintCodes ON tblProjectDetail.ReprintCo de = tblReprintCodes.Code
WHERE (((tblProjectDetail.Actual DropDate) Between [Forms]![frmSingleProjectR eport]![tx tStart] And [Forms]![frmSingleProjectR eport]![tx tEnd]))
GROUP BY tblReprintCodes.Descriptio n
HAVING (((tblReprintCodes.Descrip tion) Is Not Null));
--Steve
SELECT tblReprintCodes.Descriptio
FROM tblProjectDetail LEFT JOIN tblReprintCodes ON tblProjectDetail.ReprintCo
WHERE (((tblProjectDetail.Actual
GROUP BY tblReprintCodes.Descriptio
HAVING (((tblReprintCodes.Descrip
--Steve
Where is the Department in this query?
ASKER
Its tblReprintCodes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That didn't work.
So tell us the whole story. I'm not here to pull teeth. You display a Dept and a Count, yet only Description and Count() are in the query. Go back and have another look at your question - does it make sense?
ASKER
I think it makes sense. But if a department (Description) has a count of "0" I want that department to show up with a count of "0". I'm sorry if I'm not explaining well.
What does 'That didn't work' mean - IOW what happened when you ran the query?
Thanks, glad to help. BTW, I guess you 'discovered' that the count of a field containing all nulls will in fact be 0. Good luck with your project.
If you want that in the report footer, then add a subreport to the report footer, based on a query that uses an outer join to the tblReprintCodes table.