Passing Criteria from form to query with wild cards and "Or"

LisaLu

New member
Local time
Yesterday, 20:42
Joined
Nov 23, 2015
Messages
6
Hello,

I have a form with a text box ([text2]) on it where I have code that creates the following text from selections from a list box:

Like "*Maumelle Lake*" Or Like "*Stewardship*"

I have a query that is supposed to select records based on that box ([text2]). The sql code looks like this:

PARAMETERS [Forms]![frmLocateDocs]![Text2].[value] Text ( 255 );
SELECT tblScannedImages.DocID, tblScannedImages.Description, tblScannedImages.Tags
FROM tblScannedImages
WHERE (((tblScannedImages.Tags)=[Forms]![frmLocateDocs]![Text2]));


When I run it referencing the text box I get no results, however when I paste the contents of [text2] in the criteria, I get results.

I have also reformatted my code to create this string in my [text2]:

(tblScannedImages.Tags) Like "*Maumelle Lake*" Or (tblScannedImages.Tags) Like "*Stewardship*"

When I paste this into my query criteria I get the desired results, however when I reference [text2], again, no results.

It does not seem to matter if I put [Forms]![frmLocateDocs]![Text2].[value] vs [Forms]![frmLocateDocs]![Text2] vs [Forms]![frmLocateDocs]![Text2].[value] in the criteria field.

Any input you have would be helpful.

:banghead:

Thanks,
LisaLu
 
You can't do . . .
Code:
SomeField LIKE '*Test1*' Or LIKE '*Test2*' Or LIKE '*Test3*'
You have to do . . .
Code:
SomeField LIKE '*Test1*' Or SomeField LIKE '*Test2*' Or SomeField LIKE '*Test3*'
See the difference?
 
Yes, I used:


(tblScannedImages.Tags) Like "*Maumelle Lake*" Or (tblScannedImages.Tags) Like "*Stewardship*"

Is this what you mean?
 

Users who are viewing this thread

Back
Top Bottom