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!

How do I search for parts of a string in a field?

Status
Not open for further replies.

qu1ncy

Programmer
Jul 25, 2002
95
CA
Hello,

This started out as a post asking for help or ideas. As I was typing away, the obvious came to mind. (I'm told by my team it's an age thing!) If I combine the 2 things I had tried unsucessfully, I ended up with one solution that appears to work. I hope the following is of use to someone in the future.

Our Purchasing Dept employs a Purchase Order system developed in Access 2000 which is used for creating PO's.

The current table structure consists of a tbl_PO linked to a tbl_PODetails. The PODetails table will have the line items ordered under 1 PO number. In other words a PO number can appear many times in tbl_PODetails.

The tbl_PODetails has a field called "item_description" which stores exactly that, a string the user enters to describe the item(s) being ordered under that PO number.

My hurdle is this: Users want a report produced returning all PO information (vendor, date ordered, etc.)when they search on a portion of an item description. The way I have approached this functionality is to provide them with a blank textbox in a form called txt_Item. The user will enter their portion of the item description such as
"Access 2003" as a portion of the complete item description "077-02983 Microsoft Access 2003 License".

When they've entered their "description portion", they click a Print Preview button on the form which calls the report below.

My report is based on a query in which I have the item_description field and in it's criteria I have "*" & [Forms]![frmReporting]![txt_Item] & "*" which doesn't work.

I've tried "Like [Forms]![frmReporting]![txt_Item]" (no quotes) which doesn't work either.

Can anyone suggest what I'm doing wrong here?

** The solution which appears to work is placing (Like "*" & [Forms]![frmReporting]![txt_Item] & "*")in the criteria.

What if they enter "Access License" instead?






 
Access liscens wouldn't work.

What I have done is simliar, but I allow three fields to enter key words in.

Also, to ensure no typeing errors or extra spaces cause problems, I usually place a trim in there also.

Like "*" & trim( [Forms]![frmReporting]![txt_Item]) & "*" and Like "*" & trim( [Forms]![frmReporting]![txt_Item_1]) & "*"
 
Hey Blorf,

Your double key word search works beautifully! Users are happy. Thanks for your suggestions.

Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top