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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, Is it possible to write a qu 1

Status
Not open for further replies.

twoody54

IS-IT--Management
Apr 11, 2002
150
US
Hi,

Is it possible to write a query that looks at a field (this case Name) and ignores the first word. The data is in this format "John Doe". I just want to look at Doe for my query.

Thanks
Tom
 
It is possible, but needs a bit of VBA code to extract the last section of the name (must do that rather than everything after the first space, in case they are Jim Fred Bloggs for example).

I should point out that running VBA code from a query slows it down quite significantly.

John
 
Check out this thread, it was for a name field that uses a comma, but you can adjust it accordingly

thread701-547412

Dodge20
 
Also this might be easier, if all the data is in the same format.

SELECT Right([name],Len([name])-InStr([name]," "))
FROM customer;


Dodge20
 
Wow guys thanks for the quick responses. You solution worked dodge thanks. I think there will be an occasional record like &quot;Billy Bob Thorton&quot; or something that it won't quite work for but that can be easily corrected as there wouldn't be many <20 out of about 2000.

Thanks a lot!
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top