Extract text from field

M

Mary M

If you have a filed that contatins the following data:

LastName, FirstName

Where LastName has varing lengths. Can you run an update query to obtain
just the LastName part of the field? If so, what would be the command?

Many, many thanks in advance.
 
G

Guest

Hi Mary

This is a copy of an answer i gave last night to the same question

_______________________________________________

Create a query and bring the table containing the full name in to the top
section

Column 1 (not really neeed but to will help spot any errors) put this
FullName: [TableName]![NameOfField]

Column 2 put this
1stName:Left( [TableName]![NameOfField],InStr(1,
[TableName]![NameOfField],",")-1)


Column3 put this
2ndName: Right(Trim( [TableName]![NameOfField]),Len(Trim(
[TableName]![NameOfField]))-InStr(1, [TableName]![NameOfField]," "))


Change
TableName to what is it is
NameOfField to the name of the field containing the name and commas.

Hope this helps
 
J

John W. Vinson

If you have a filed that contatins the following data:

LastName, FirstName

Where LastName has varing lengths. Can you run an update query to obtain
just the LastName part of the field? If so, what would be the command?

Many, many thanks in advance.

Sure. Update LastName to

Left([fullname], InStr([fullname], ",") - 1)

and FirstName to

Trim(Mid([fullname], InStr([fullname], ",") + 1))

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top