View Full Version : extracting data from a field in a table.


darksniper
01-29-2007, 10:48 AM
when I have created my table I have created a field called name that stored both last and first name. Right now I need to extract the the last name from the the field name and store it in another field "lastName". Any ways to do that?

FoFa
01-29-2007, 11:11 AM
Yes, depending on the format in the "name" field will be how hard or easy it is.

darksniper
01-29-2007, 05:08 PM
it is a text field. and the data in that field would be something like this: "John Wood" or "Arnold Terminator" as an example.

Moniker
01-29-2007, 06:26 PM
If the separator between first and last name is always a space and you have no middle names, this will work:


LastName = Right([Name],Len([Name])-InstrRev([Name]," "))
FirstName = Trim(Left([Name],InStr(1,[Name]," ")))

darksniper
01-29-2007, 09:16 PM
thx, I'll try it out right away!

darksniper
01-30-2007, 06:34 AM
allthough the only thing I forgot to ask, where do I put the code?

neileg
01-30-2007, 07:00 AM
As a calculated field in a query.

darksniper
01-30-2007, 02:44 PM
works great, thx...