HasData Expression

tafnuef1

Registered User.
Local time
Today, 05:54
Joined
Apr 22, 2010
Messages
43
Ok, I have a Main Report currently named Prepper, I have a Subreport named Prepper 2 Query Data.

In the subreport there is a control that is a calculated Count of another control on the sub report (Prepper Error) the calculation is counting the number of Prepper Errors. Ok that works fine.

What I am trying to do is that I want to have the Calculation from the subreport on the Main report (Prepper).

So in the Source code I have been told that I use the HasData Expression if I want the calculation to be zero if there are no errors but if there is errors I want the calculation.

What I did was this:

=IIf([Reports]![Prepper 2 Query Detail]![AccessTotalsPrepper Error].[Report].[HasData],[Reports]![Prepper 2 Query Detail]![AccessTotalsPrepper Error],0)

Ok the return value in my box is #Name? so I know I typed this all wrong. Can someone help me clean this up?
 
Would this be what you would do? And how would you do it? right click the control and choose to Build Event and place it in there?


Private Sub Total_Error_Count_BeforeUpdate(Cancel As Integer)
If Not Me.Prepper_2_Query_Detail.Access_Totals_Prepper_Error Then
nnz = 0
Else
nnz = Me.Prepper_2_Query_Detail.Access_Totals_Prepper_Error
End If
End Sub
 
No, you'd copy/paste that function into a standard module so it can be called from anywhere. Then your textbox control source is:

=nnz(Reports![Prepper 2 Query Detail]![AccessTotalsPrepper Error])

If you need help with the syntax to refer to a subform/subreport:

http://www.mvps.org/access/forms/frm0031.htm
 
I know this sounds a bit daft but do the report the other way round start at Prepper2 and link the Prepper2 info to Prepper. The logic is that the Prepper info is descriptive and providing there is Groupings and a Header/Footer on the Prepper info you are achieving the same thing:

Header Prepper
Detail Prepper2

Simon
 

Users who are viewing this thread

Back
Top Bottom