By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,395 Members | 2,541 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,395 IT Pros & Developers. It's quick & easy.

separating a string

P: n/a
I have a field that has names in it in the format "last name, first
name". I want code that will split this field for me at the comma so I
can make 2 separate fields for last name and first name. Thanks.

Dec 24 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ja*******@yahoo.com wrote:
I have a field that has names in it in the format "last name, first
name". I want code that will split this field for me at the comma so
I can make 2 separate fields for last name and first name. Thanks.
FirstName: Mid([FieldName], InStr(1, [FieldName], ", ")+2)

LastName: Left([FieldName], InStr(1, [FieldName], ", ")-1)

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Dec 24 '06 #2

P: n/a
Just incase some records don't have a space
LastName = Left([FieldName], Instr([FieldName], ",")-1)
FirstName = Trim(Mid([FieldName], Instr([FieldName], ",")+1))

<ja*******@yahoo.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
>I have a field that has names in it in the format "last name, first
name". I want code that will split this field for me at the comma so I
can make 2 separate fields for last name and first name. Thanks.

Dec 24 '06 #3

P: n/a

ja*******@yahoo.com wrote:
I have a field that has names in it in the format "last name, first
name". I want code that will split this field for me at the comma so I
can make 2 separate fields for last name and first name. Thanks.
dim data as string
dim fields() as string
dim last as string
dim first as string

data = "Last name, first name"
fields = split( data, ",")
last = trim( fields(0) )
if ubound( fields ) 0 then
first = trim(fields(1))
end if

Cheers

Keith

Dec 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.