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

templeowls

Registered User.
Local time
Today, 06:00
Joined
Jun 11, 2019
Messages
130
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, 09:00
Joined
Apr 9, 2015
Messages
3,936
me.filter ="[Status]= 'Open' and [HighLevelComplaint]= 'Yes'"
me.filterOn = true
 

Ranman256

Well-known member
Local time
Today, 09:00
Joined
Apr 9, 2015
Messages
3,936
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
 

templeowls

Registered User.
Local time
Today, 06:00
Joined
Jun 11, 2019
Messages
130
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