Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Filter through "OR" statement in a field.

$
0
0

[If this is the incorrect Forum for this question I apologize and let me know so I may move it, but did not find a proper one for Microsoft Access 2007.]  Completely new to access and have only had a few hours experience with this, so pardon my terminology and horrible code.  I am attempting to created a query-able database for three types of documents at my work (ER, TN, and AID).  I have been able so far as to filter a table on my form from one type of report to another (through checkboxes) but when I have 2 boxes selected it tries to read (for example) "ER or TN".  In the future it should be able to filter through some AND statements across fields as well.  I found some code (Thank you to  "r_cubed") on a forum which they wrote that will perform AND statements between fields but what I need is an "OR" statement for within the field.  Here is what I have (modeled off of code found from user: r_cubed):

Private Sub Button_FilterOn_Click()

    Dim strFilter As String
   ' Dim strFilter1 As String
   ' Dim strFilter2 As String
        strFilter = ""
    '    strFilter1 = ""
    '    strFilter2 = ""
       
If Check_ER = True Then
    strFilter = strFilter & "ER" & " or "
End If

If Check_TN = True Then
    strFilter = strFilter & "TN" & " or "
End If

If Check_AID = True Then
    strFilter = strFilter & "AID" & " or "
End If

If strFilter = "" Then
    MsgBox ("No Criteria To Search With Please Try Again!") '
Else
    strFilter = Left$(strFilter, Len(strFilter) - 4)

    MsgBox strFilter
        'Form_SubformList.Filter = "Report_Type = '" & strFilter & "'" 'Works for single
        'Form_SubformList.Filter = "Report_Type = 'IN(" & strFilter & ")'"
        Form_SubformList.Filter = "Report_Type = '" & strFilter & "'"
        Form_SubformList.FilterOn = True
       
End If
End Sub


Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>