T-Rex
T-Rex

Reputation: 161

Multiple Field Filtering Requirements

The strFilter results in the following, but will not carry through to the Me.Filter, any ideas why?
strFilter = "'20410' OR 'A20000' OR 'A20400'"

Private Sub Image_OffsetFilterButton_Click()
Dim strFilter As String
strFilter = "'A20410'"
   '/ see if there is data in Field Box Text907, if so add it to the filter
    If Me!Text907 & vbNullStr <> vbNullStr Then
   strFilter = strFilter & " OR " & "'" & "A20000" & "'"
End If
   If Me!Text910 & vbNullStr <> vbNullStr Then
  ' If FieldB is of Text type, use the ' delimiter
   strFilter = strFilter & " OR " & "'" & "A20024" & "'"
End If
  If Me!Text911 & vbNullStr <> vbNullStr Then
 ' If FieldB is of Text type, use the ' delimiter
  strFilter = strFilter & " OR " & "'" & "A20400" & "'"
End If
 '/<etc>


If strFilter <> "" Then
' trim off leading "OR"
  Me.Filter = "[Account] = strFilter AND [BU] = 'B50931'"
  Me.FilterOn = True
Else
  Me.Filter = ""
  Me.FilterOn = False
End If

End Sub

Upvotes: 0

Views: 195

Answers (1)

T-Rex
T-Rex

Reputation: 161

Private Sub Image_OffsetFilterButton_Click()
Dim strFilter As String
strFilter = ""
'/ see if there is data in Field Box Text907, if so add it to the filter
 If Me!Text907 & vbNullStr <> vbNullStr Then
  strFilter = strFilter & " OR [ACCOUNT] = '" & Me.Text907 & "'"
  End If
 If Me!Text910 & vbNullStr <> vbNullStr Then
  '/ If FieldB is of Text type, use the ' delimiter
   strFilter = strFilter & " OR [ACCOUNT] = '" & Me.Text910 & "'"
   End If
If Me!Text911 & vbNullStr <> vbNullStr Then
   '/ If FieldB is of Text type, use the ' delimiter
   strFilter = strFilter & " OR [ACCOUNT] = '" & Me.Text911 & "'"
 End If
'/<etc>

   If strFilter <> "" Then
   '\ trim off leading "OR"
   Me.Filter = Mid(strFilter, 4)
   Me.FilterOn = True
Else
    Me.Filter = "[BU] = [Forms]![Frm_Main]!    [Frm_Main_TextBox_Display_BU_Number_HIDDEN].Value"
   Me.FilterOn = False
End If
End Sub

Upvotes: 1

Related Questions