Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Criteria for query on the fly to search any part of field 2

Status
Not open for further replies.

netrusher

Technical User
Joined
Feb 13, 2005
Messages
952
Location
US
I would like to enter search critiera for a query on the
fly. The field I want to search is a memo box. I would
like to start the query from a command button and then
enter the search criteria. I can do that but I can't seem
to do wildcard search i.e. I would like to search for a
part number that is just a part of the memo field that I am
searching. When I try to add the *123456* it will not find
the part number 123456. How can I add criteria on the fly
to only find any part of the memo field?
 
Below is the code I currently have. When the query is ran
a pop-up comes up and says Enter Search Criteria:. How can the
search criteria be entered here to find the partial text or number?

Code:
SELECT all_trucks_table.[Form #], all_trucks_table.[What Changed]FROM all_trucks_tableWHERE (((all_trucks_table.[What Changed])=[Enter Search Criteria:]));
 
you have to use the LIKE operator not the = operator:

Code:
SELECT all_trucks_table.[Form #], all_trucks_table.[What Changed]FROM all_trucks_table WHERE (((all_trucks_table.[What Changed]) LIKE *&[Enter Search Criteria:]&*));

(note I don't use Access much, so the format of the *& may be incorrect, but you should get the idea!!)

Leslie

In an open world there's no need for windows and gates
 
IMHO, parameter prompts are not appropriate. I suggest adding a text box on your form for users to enter the text they want to search for. Then your SQL would look like:
Code:
SELECT [Form #], [What Changed]
FROM all_trucks_table
WHERE [What Changed] Like "*" & Forms!frmYourForm!txtSearch & "*";

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top