My Assistant
![]() ![]() |
|
|
Mar 3 2012, 03:58 PM
Post
#1
|
|
|
UtterAccess Addict Posts: 124 |
The code below is in a report I have created.
[Text80] = DCount("[PNCR Number]", "[MRB Report]", "[Product Disposition] = 'No Fault Found'") The issue I have is that I use a date filter to filter the report. When opening the report I can enter a begining and end date and only show the data between those dates. Problem is that the DCount function does not seem to filter and counts ALL the records in the query whether filtered or not. How can I fix this issue? Please Help... This post has been edited by lorenambrose: Mar 3 2012, 04:04 PM |
|
|
|
Mar 3 2012, 04:02 PM
Post
#2
|
|
|
Access Wiki and Forums Moderator Posts: 48,059 From: SoCal, USA |
Hi,
What version of Access are you using? Knowing the Access version may help us determine a more appropriate response to your question. Where do you have that code running from? Are you using a parameter query for the report? If so, you could try using the same name as the parameters in your DCount() function as well. Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Mar 3 2012, 04:05 PM
Post
#3
|
|
|
UtterAccess Addict Posts: 124 |
Sorry about that.... I am using Access 2007
|
|
|
|
Mar 3 2012, 06:14 PM
Post
#4
|
|
|
UtterAccess Addict Posts: 124 |
Hi, What version of Access are you using? Knowing the Access version may help us determine a more appropriate response to your question. Where do you have that code running from? Are you using a parameter query for the report? If so, you could try using the same name as the parameters in your DCount() function as well. Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) The code is in the "On Load" event in the report itself. |
|
|
|
Mar 3 2012, 07:52 PM
Post
#5
|
|
|
Access Wiki and Forums Moderator Posts: 48,059 From: SoCal, USA |
The code is in the "On Load" event in the report itself. Is Text80 bound to anything? If not, why not just put the DCount() expression it its Control Source and take it out of the Report's OnLoad event? Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Mar 3 2012, 10:20 PM
Post
#6
|
|
|
UtterAccess Addict Posts: 124 |
Is Text80 bound to anything? If not, why not just put the DCount() expression it its Control Source and take it out of the Report's OnLoad event? Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) Not sure I follow how to do that. |
|
|
|
Mar 3 2012, 10:32 PM
Post
#7
|
|
|
UtterAccess Addict Posts: 124 |
Ok, so I added the code below to the Control Source of Text80 and it works just like in the Report's "On Load" event. I am getting very frustrated.
= DCount("[PNCR Number]", "[MRB Report]", "[Product Disposition] = 'No Fault Found'") The report is filtered prior to opening. I select the report and enter a begining and end date as applicable and only those records show up in the report. This post has been edited by lorenambrose: Mar 3 2012, 10:53 PM |
|
|
|
Mar 4 2012, 09:48 AM
Post
#8
|
|
|
Access Wiki and Forums Moderator Posts: 48,059 From: SoCal, USA |
Hi,
Like I said earlier, if the report is using a parameter query, you'll need to use the same parameters in your DCount() expression. Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Mar 4 2012, 02:56 PM
Post
#9
|
|
|
UtterAccess Addict Posts: 124 |
Well I got it worked out:
=Sum(IIf([Product Disposition]="No Fault Found",1,0)) Frankly, I am not exactly sure what this code says but I think it is assigning a "1" to every "No Fault Found" and then adding them up. Is this correct? |
|
|
|
Mar 4 2012, 04:56 PM
Post
#10
|
|
|
Access Wiki and Forums Moderator Posts: 48,059 From: SoCal, USA |
Hi,
Glad to hear you got it sorted out. That is correct, you are assigning a value of 1 to each "No Fault Found" record and then totalling them up in the end. Good luck with your project. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 07:50 PM |