Trying to use a button to apply multiple filters... (1 Viewer)

gojets1721

Registered User.
Local time
Today, 12:28
Joined
Jun 11, 2019
Messages
429
I am trying to use a button in my form to apply multiple filters but I'm not doing something right because its only applying one filter when selected. Here's my VBA:

Code:
Private Sub btnPROpen_Click()
    DoCmd.ApplyFilter , "[Status]= 'Open'"
    DoCmd.ApplyFilter , "[HighLevelComplaint]= 'Yes'"
End Sub

Any ideas?
 

Ranman256

Well-known member
Local time
Today, 15:28
Joined
Apr 9, 2015
Messages
4,339
me.filter ="[Status]= 'Open' and [HighLevelComplaint]= 'Yes'"
me.filterOn = true
 

Ranman256

Well-known member
Local time
Today, 15:28
Joined
Apr 9, 2015
Messages
4,339
if using many controls to filter:

Code:
sub btnFind_click()
sWhere = "1=1"
if not isnull(cboState) then sWhere = sWhere & " and [state]='" & cboState & "'"
if not IsNull(txtName) then sWhere = sWhere & " and [Name]='" & txtName & "'"
if not IsNull(cboGender) then    sWhere = sWhere & " and [Gender]='" & cboGender & "'"

'then filer
if sWhere = "1=1" then
me.filterOn = false
else
me.filter = sWhere
me.filterOn = true
endif
end sub
 

gojets1721

Registered User.
Local time
Today, 12:28
Joined
Jun 11, 2019
Messages
429
One more related question...say I have a form full of complaint entries and there's a field that lists the employee responsible.

Say I'm on an entry listing John Smith as the employee responsible. Is there a way to make a filter that filters to all entries that have John Smith listed in that field?

I'm a novice and thought something like below might work but no luck

Code:
DoCmd.ApplyFilter , "[EmployeeResponsible]= Me"
 

Users who are viewing this thread

Top Bottom