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!

Only return part of a field in query

Status
Not open for further replies.

Eprice

Technical User
May 6, 2003
209
US
Hi,
I have fields in a table "Mac Industries PCole", Mac Industries LPrice" & Mac Industries JDoe". What I want to do in a query is only bring in Mac Industries. My problem is the spaces between the customer name and agent name isn't always the same. Does anyone know how to get only the name in the query field?
Thanks
Lisa
 
Hi,

In the Criteria
[tt]
Like '*Mac Industries*'
[/tt]


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Why not just:

select left([myfield],len("Mac Industries")) from mytable?

This assumes all the fields have "Mac Industries" as the prefix.

Mike Pastore

Hats off to (Roy) Harper
 
I should explain more. It will not alway be Mac Industries, there are other customer names and sometimes they put a name after the customer name and sometimes they dont. Thats why this doesnt work:
Ins: (Left([tbl RCS]!INS_NAME,InStr(1,[INS_NAME]," ")-1))
That works if they have the extra name but if it were just "Mac Industrise" I get an error. The expression is typed incorrectly or is too complex.....
Lisa
 
I got it! this works.
Ins: IIf(InStr([INS_NAME]," "),(Left([tbl RCS]!INS_NAME,InStr(1,[INS_NAME]," ")-1)),[INS_NAME])
Thanks for your help.
Lisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top