MS Access How to Count Unique Records or Values On a Filtered Report

青春壹個敷衍的年華 提交于 2019-12-13 03:27:24

问题


All,

I have a query called "WCR_Q" and a report called "WCR_R" based off of this query. My report is filtered based off a record selection from a form. When I use the expression =Count[FacilityID] becuse I get a total number of records in the query instead of the total number of records as displayed in my report. The query has (6) records for [FacilityID] but there's only (2) [FacilityID] in my report. This is due to the query having duplicates. I need an expression formula to place in my control that will count only unique records in the query or only count the records expressed on the report.

I've tried:

 =Count([FacilityID])
 =DCount("[FacilityID]","WCR_Q",DCount("[FacilityID]","WCR_Q","FacilityID =" & [FacilityId])>0)
 =DCount("[FacilityID]","WCR_Q","FacilityID =" & [FacilityID])
 =DCount("[FacilityID","[WCR_Q]","[FacilityID]=" & [FacilityID])>0
 =Count(IIf("FacilityID <>" & [FacilityID],0))
 =DCount("[FacilityID]","WCR_Q",[FacilityID])
 =DCount("[FacilityID]","WCR_Q","FacilityID <>" & [FacilityID])

I have tried the count functions in the Facility grouping and the Campaign grouping and it returns a value of (6) instead of (2) expressed in report.

I'm new to writing expressions and designing reports in Access so please help if anyone knows how to count unique values in a control box. Thanks!!!


回答1:


Thank you so much C. Perkins. I spent so much time trying to figure out a solution to this. Thank you for your time to post the reply.

Here's what I DID: Add a textbox to the group header and set the Running Sum property to Over Group, the Visible property to No, the Control Source to =1 and the Name to, say, GroupCount. I created another textbox in the header and set the Control Source to =GroupCount.



来源:https://stackoverflow.com/questions/53182120/ms-access-how-to-count-unique-records-or-values-on-a-filtered-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!