Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-14-2014, 06:18 AM   #1
thmsjlmnt3953
Newly Registered User
 
Join Date: May 2014
Posts: 120
Thanks: 15
Thanked 3 Times in 3 Posts
thmsjlmnt3953 is on a distinguished road
Form filter and exclude with check box

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

thmsjlmnt3953 is offline   Reply With Quote
Old 08-14-2014, 03:37 PM   #2
jdraw
Super Moderator
 
jdraw's Avatar
 
Join Date: Jan 2006
Location: Ottawa, Ontario, Canada;West Palm Beach, Florida
Posts: 12,142
Thanks: 81
Thanked 2,010 Times in 1,958 Posts
jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light
Re: Form filter and exclude with check box

see this for another approach

good luck.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jdraw is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
docmd.apply filter - to exclude matched records matt beamish Modules & VBA 2 06-13-2014 07:54 AM
Filter form with selected check boxes obs Forms 1 08-16-2007 06:48 PM
Possible to color certain entries? exclude filter? Print options? can General 7 07-12-2005 06:46 AM
how to include or exclude based on a check box Milothicus Queries 2 01-06-2005 02:50 AM
Using check box to exclude records uplink600 Forms 5 08-19-2004 06:21 PM




All times are GMT -8. The time now is 06:08 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World