Query With Like Criteria Linked to Text Box on Form

Jamsandwich

New Member
Joined
Sep 25, 2014
Messages
44
Hey guys,

I have a form with a text box that allows a user to input anything.

I'm using this text box as a parameter for a query.

So I'd like to return records that contain the input from the text box in a specified field.

I have put my required fields into the query and added the following criteria to the necessary field -

Code:
Like "*" & [Forms]![frm_Reports]![txtpTitle] & "*"

This doesn't appear to be returning anything at all though, no matter what is entered into the text box. Am I missing a step somewhere? Or is my criteria typed in wrong?

If nothing is entered or if I don't hit Enter upon typing on the box then the query returns all records.

For reference, here is the generated SQL

Code:
SELECT Projects.p_ID, Projects.p_Title, Projects.p_Description, Projects.p_Department, Projects.[p_Project Lead], 
       Projects.p_Priority, Projects.p_Status
FROM Projects INNER JOIN Functions ON Projects.p_ID = Functions.f_pID
WHERE (((Projects.p_ID) Like "*" & [Forms]![frm_Reports]![txtpTitle] & "*"));
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Like "*" & [Forms]![frm_Reports]![txtpTitle] & "*"

Code:
Like chr$(34) & "*" & [Forms]![frm_Reports]![txtpTitle] & "*" & chr$(34)

The above expression will enclose the whole Like criterian in double quotes: Like "*ABCD*"
 
Upvote 0
Have you got the criteria in the right field in the query? It looks like it's in the ID field. By the look of the name of your textbox, should it be in the p_Title field?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,808
Messages
6,162,097
Members
451,742
Latest member
JuanMark10

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