Can someone tell me why this DCOUNT returns the number of records in the query without regard to the criteria? Thank you in advance.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Increment iLine on each detail format
Static iLine As Integer
iTotal = DCount("[ContactID]", "qryCompanyContacts", Me.[CompID] = 171)
'iTotal = DCount("[ContactID]", "qryCompanyContacts", Me.[CompID] = Reports![Dues Invoice]![CompID])
iLine = iLine + 1
If iLine < iTotal Then
'do nothing, print as usual
ElseIf iLine = iTotal Then
'if there are more lines to print, set the NextRecord property to false, preventing the report from exiting prematurely
If iLine < iLines Then Me.NextRecord = False
Else
'set font to white for padded row controls
'MsgBox ("Blank Line")
Me!Text9.ForeColor = vbWhite
Me!CompID.ForeColor = vbWhite
Me!Email.ForeColor = vbWhite
'prevent report from advancing past last row until all of blank lines have printed
If iLine < iLines Then
Me.NextRecord = False
ElseIf iLine > iLines Then
iLine = 0
Me!Text9.ForeColor = 4210752
Me!CompID.ForeColor = 4210752
Me!Email.ForeColor = 4210752
End If
End If
End Sub
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Increment iLine on each detail format
Static iLine As Integer
iTotal = DCount("[ContactID]", "qryCompanyContacts", Me.[CompID] = 171)
'iTotal = DCount("[ContactID]", "qryCompanyContacts", Me.[CompID] = Reports![Dues Invoice]![CompID])
iLine = iLine + 1
If iLine < iTotal Then
'do nothing, print as usual
ElseIf iLine = iTotal Then
'if there are more lines to print, set the NextRecord property to false, preventing the report from exiting prematurely
If iLine < iLines Then Me.NextRecord = False
Else
'set font to white for padded row controls
'MsgBox ("Blank Line")
Me!Text9.ForeColor = vbWhite
Me!CompID.ForeColor = vbWhite
Me!Email.ForeColor = vbWhite
'prevent report from advancing past last row until all of blank lines have printed
If iLine < iLines Then
Me.NextRecord = False
ElseIf iLine > iLines Then
iLine = 0
Me!Text9.ForeColor = 4210752
Me!CompID.ForeColor = 4210752
Me!Email.ForeColor = 4210752
End If
End If
End Sub