THIS DOES NOT WORK ON A SUB FORM USE ME.FILTER
Example of DoCmdApplyfilter:-
- Where you are using a TEXT box on the form to get your criteria from
- TBQueryCompany & TBQueryCompany are text box names
- Refresh after
- DoCmd.ShowAllRecords clears all filters
Private Sub TBQueryCompany_AfterUpdate()
DoCmd.ApplyFilter , "department = '" & TBQueryCompany & "'"
Refresh
End Sub
Private Sub TBQueryPerson_AfterUpdate()
DoCmd.ApplyFilter , "[Employee Name] = '" & TBQueryPerson & "'"
Refresh
End Sub
Private Sub Command140_Click()
DoCmd.ShowAllRecords
TBQueryCompany = "*" (Sets the relevant field to *)
###############################################################
Example of DoCmdApplyfilter:-
- Where you are using a FIXED string value / criteria
Private Sub Command15_Click()
DoCmd.ApplyFilter , "Status='Removed'"
Filtered.Visible = True
End Sub
Links
Remove Filters Problem
https://blueclawdb.com/access-database/tutorials/docmd-applyfilter-example/