Query Keywords from a Keyword Table

brncao

Board Regular
Joined
Apr 28, 2015
Messages
147
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.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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:
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,049
Latest member
THMarana

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