Avatar of joylene6
joylene6
Flag for United States of America asked on

Statement to split out first and last name in query

Hello.  I have a field that has a persons first and last name formatted like this  
LASTNAME, FIRSTNAME

I need to split them out into to fields in my query.

So - how do I get everything BEFORE the comma in one cell.... and everything AFTER the comma in another cell?  also I would like everything after the comma not to have a space between , Firstname.

Thanks
Microsoft AccessMicrosoft ApplicationsSQL

Avatar of undefined
Last Comment
joylene6

8/22/2022 - Mon
Ken Butters

You can use the split function after retrieving from the query:

dim arr as variant

arr = Split(YourString, ",")

That being said, a much better (and easier) Database design would be to define separate columns for first name and last name.   That way you can join them easily in any manner you need to.

You should never combine more than one object (such as first and last name) into a single column.

A similar design should also apply to addresses.  you would not want to make one field called address and then store all of street address, city, state, zip all in the one field.  You should make a separate column for each of them.
ASKER CERTIFIED SOLUTION
Shaun Kline

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
joylene6

ASKER
Thanks will give it a try
joylene6

ASKER
Shaun Kline - thanks that worked!

Ken - the database had information in it that I could not change and did not create, but yes I totally agree with you

Thanks
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck