Form filter and exclude with check box (1 Viewer)

thmsjlmnt3953

Registered User.
Local time
Today, 03:09
Joined
May 20, 2014
Messages
120
Hi,

I have the following code which builds a filter on my form which i can then generate a report from.

However id like to add a check box to exclude rather than include a certain [Error_Type] which is "Wrong Batch" and im not sure how id do it..

the vba i have so far is as follows

Code:
Private Sub cmdFilterConvErrors_Click()
 Dim strWhere As String
    Dim lngLen As Long
    Const conJetDate = "\#mm\/dd\/yy\#"

    If Not IsNull(Me.txtqccheckby) Then
        strWhere = strWhere & "([Error_QC_By] = """ & Me.txtqccheckby & """) AND "
    End If
    If Not IsNull(Me.txtTSM) Then
        strWhere = strWhere & "([Error_TSM] = """ & Me.txtTSM & """) AND "
    End If
    If Not IsNull(Me.txtType) Then
        strWhere = strWhere & "([Error_Type] = """ & Me.txtType & """) AND "
    End If
    If Not IsNull(Me.txtRecordedBy) Then
        strWhere = strWhere & "([empname] = """ & Me.txtRecordedBy & """) AND "
    End If
    If Not IsNull(Me.txtStartDate) Then
        strWhere = strWhere & "([Error_Date] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
    End If
    If Not IsNull(Me.txtEndDate) Then
        strWhere = strWhere & "([Error_Date] < " & Format(Me.txtEndDate + 1, conJetDate) & ") AND "
    End If

    lngLen = Len(strWhere) - 5
    If lngLen <= 0 Then
        MsgBox "No criteria", vbInformation, "Nothing to do."
    Else
        strWhere = Left$(strWhere, lngLen)

        
        Me.Filter = strWhere
        Me.FilterOn = True
    End If
End Sub
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 22:09
Joined
Jan 23, 2006
Messages
15,379
see this for another approach

good luck.
 

Users who are viewing this thread

Top Bottom