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
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.
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.