Query Keywords from a Keyword Table

brncao

Board Regular
Joined
Apr 28, 2015
Messages
134
In the Criteria field, I would like to avoid the "Or Like" redundancy and would prefer to use a table of keywords instead of typing it all into the Criteria.
SQL:
Like "*ABC*" Or Like "DEF*" Or Like "*GHI"...
Is there a way to to do something akin to "Like KeywordTable?" This is in Access. Macros are acceptable.

Thanks.
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,974
Office Version
  1. 365
Platform
  1. Windows
What I would probably do is create it in VBA. You can use DAO/ADO recordsets, to loop through your "Keyword" table, and create your long string of "OR" statements.
Then, you can write the SQL code you need for your query and apply it.
Here is a link that shows you how run SQL code from VBA: Build SQL statements that include variables and controls

Here is also a little hint. To figure out what your SQL code needs to look like, using Access's query builder, create a simple query that has what you are looking for, but only with the first few "OR" statements. Then, switch the query to SQL View. This is what the SQL code you are trying to create needs to look like (just with more OR statements). Then, when you are using VBA to build this, you can use a MsgBox command to view your SQL Query string. You can then compare it to the sample you created, and keep working this way until you have it correct.

Here is a link that shows you how to loop through all the records in your Keyword table to create the criteria portion of your SQL string:
 

Watch MrExcel Video

Forum statistics

Threads
1,123,229
Messages
5,600,420
Members
414,383
Latest member
kevinlarey

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
Top