Update query question

M

Mandi

I have a text field [name] with names like:
Doe, John
Smith, Jim

I also have 2 other text fields that are currently blank
[f_name] and [l_name]

How do I create an update query to put only the last name
in [l_name] and only the first name in [f_name] (from the
[name] field? (I know there is a function that will help
me do this...)

Any assistance is appreciated! Thanks!
 
R

Rick Brandt

Mandi said:
I have a text field [name] with names like:
Doe, John
Smith, Jim

I also have 2 other text fields that are currently blank
[f_name] and [l_name]

How do I create an update query to put only the last name
in [l_name] and only the first name in [f_name] (from the
[name] field? (I know there is a function that will help
me do this...)

UPDATE YourTableName
SET f_name = Mid([name], InStr(1, [name], ",")+2),
l_name = Left([name], InStr(1, [name], ",")-1)

BTW One should never name any of your own fields or controls name. Since many Access
and VBA objects have a property named name, this can cause Access to get confused
about whether you mean the object named name or the property named name. (see how
confusing that looks?)

If that field is going to stick around (and it shouldn't) then change it to FullName
or similar.
 

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

Similar Threads


Top