command button that calls a text filter

QCMan

New Member
Joined
Jan 16, 2016
Messages
11
I have a form that I input data in. on this form I want a command button that will act just as if I right click on a field and apply a text filter that equals "my input". Yes it is easy to right click and scroll down to "text Filter" then enter but I want to eliminate the right click portion of this step, as I am constantly trying to find something in this field. I have tried several VBA commands and the built in macros but they aren't cooperating with me. Been to several sites and looked over many forums but none have prevailed. The table is not indexed, as it was a basic import from and excel spreadsheet and at the time I didn't want it indexed. In the future it will be.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
What is the source of the form - a table ?
Where is the text to be applied as filter - in a textbox?

What I would do is - use a QUERY (instead of a table ) which includes all necessary table fields. As a criteria for the field to be filtered - use something like: LIKE Nz([form].[textbox1],"*"). Since the query will include only one table - the recordset will be updatable.
(may need some digging to make the LIKE to work - in my case it is ALIKE "%")
Then for the textbox in a code for AfterUpdate event include Me.Requery
When the textbox is empty it should show all records, otherwise - filtered.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,799
Messages
6,162,030
Members
451,738
Latest member
gaseremad

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top