Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Concurrent Filters on a Form

$
0
0
:) Dear all,

I have a form with different fields, and a few hundred records.

My objective is to be able to use different filters at the same time:
(1) 2 filters on 2 fields that can take only 2 values ("F" or not "F" for the first field, TRUE or FALSE for the second).
I already have 2 sets of 2 checkboxes that control filters based on these fields.
Code:

Public Sub CheckNCRStatusF_Click()
If CheckNCRStatusF = True And CheckNCRStatusNonF = True Then
DoCmd.ShowAllRecords
Else
If CheckNCRStatusF = True And CheckNCRStatusNonF = False Then
DoCmd.ApplyFilter , "[NCR Status] = 'F'"
Else
If CheckNCRStatusF = False And CheckNCRStatusNonF = True Then
DoCmd.ApplyFilter , "[NCR Status] <> 'F'"
Else
DoCmd.ApplyFilter , "[NCR Status] = '9899' "
'9899 is an impossible value'
End If
End If
End If
End Sub

(2) several filters on other fields where upon clicking a button the form requests the use to input (InputBox) a string that will be searched in this one field.
Until now, I used something like :
Code:

DoCmd.ApplyFilter , "InStr(1, [Report Issuer], searchtext, 1) <> 0"
What are the issues?
(a) I can't use InStr with a text string defined elsewhere instead of a mere local variable (here, searchtext)
I would like to have something like:
Code:

dim searchtext as As String
searchtext = "John"
DoCmd.ApplyFilter , "InStr(1, [Report Issuer], searchtext, 1) <> 0"

(b) I can't use different filters at the same time. This is the biggest problem I have.
I would like to be able to click on a first button to filter all records for which the [Status] = "F", and then to click another button leading to the input box to search the [Report Issuer] field.
I don't want the second filter to replace the first one but the two filters to be applied simultaneously.


Thanks for reading ;)

Tarik

Viewing all articles
Browse latest Browse all 13329

Trending Articles