Avatar of mriozzo68
Flag for United States of America

asked on 

Using wildcards with a LIKE statement

This is a continuation of a previous question (http://bit.ly/2yRemJp).

I have a textbox (key_sel) on a form (switchboard) that I want to allow the user to enter in a series of values separated by a semicolon, which will then be used as criteria in a query.

SQL statement is below:
keysql = "SELECT dbo_sys1_key_codes.key_code FROM dbo_sys1_key_codes Where key_code LIKE ('" & Replace(Trim(Forms!Switchboard!key_sel), ";", "' or '") & "')"

If I use one value (*2XH07) the query runs fine and pulls the correct data.  When I specify multiple criteria (I used *2XH07;*9XH16 as the value) it pulls no data.  When I design view the query the query the criteria is below.  Obviously the first "Like " is creating the problem.  

Like (Like '*2XH07' Or Like '*9XH16')

Don't know what I'm doing wrong.
Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon