It sounds like you want to Count the number of AppNum (is that your PK?) if those conditions are met.
What you probably want to do is to create a check box on the Detail Section, and set Visible to No. Then on the Detail Section's On Format event, put this code (this assumes that there are no Nulls in the MinInc fields):
Dim nMinInc1 As Long
Dim nMinInc2 As Long
Dim b1 As Boolean
Dim b2 As Boolean
b2 = False
b1 = False
nMinInc1 = Me.MinInc1
nMinInc2 = Me.MinInc2
If nMinInc1 >= 0 And nMinInc1 >= 7 Then
b1 = True
Else
b1 = False
End If
If nMinInc2 >= 0 And nMinInc2 >= 7 Then
b2 = True
Else
b2 = False
End If
If b1 = True OR b2 = True Then
Me.chkMins = True
Else
Me.chkMins = False
End If
Then you can do this in a Textbox on the header or footer of the report:
=Sum(IIf([chkMins]=True, 1, 0))
You may have to play around with this, like
=Sum(IIf([chkMins]=Yes, 1, 0))
=Sum(IIf([chkMins]=1, 1, 0))
=Sum(IIf([chkMins]=-1, 1, 0))
=Sum(IIf([chkMins]<>0, 1, 0))
I am not sure which one it will pick up for a check box.
Okay, that is real brute force coding. Does someone have a much more elegant way of doing this? I know there must be.
HTH
mmcdonal
|