HI,
I am writing a query which split fullname field into separate columns(firstname,middlename,lastname,title or suffix).
Here is my query so far and it seems to be working fine except for the ones with title or suffixes.
Query:
---------
Module:
----------
For ex: Aquilio, III, John gives me results like this:
firstname - III
Middlename -
Lastname - Aquilio
Suffix -
I am expecting a result like this:
firstname - John
Middlename -
Lastname - Aquilio
Suffix - III
Thanks for any help.
I am writing a query which split fullname field into separate columns(firstname,middlename,lastname,title or suffix).
Here is my query so far and it seems to be working fine except for the ones with title or suffixes.
Query:
---------
Code:
SELECT Participants.[Full Name], GetNamePortion([Full Name],1) AS FirstName, GetNamePortion([Full Name],2) AS MiddleName, GetNamePortion([Full Name],3) AS LastName, GetNamePortion([Full Name],4) AS Suffix
FROM Participants;
Module:
----------
Code:
Function GetNamePortion(NameStr As String, PortionNum As Long) As String
Dim arr As Variant
Dim arr2 As Variant
Dim arr3 As Variant
On Error Resume Next
arr = Split(NameStr, ", ")
arr2 = Split(arr(1), " ")
arr3 = Split(arr(0), " ")
Select Case PortionNum
Case 1: GetNamePortion = arr2(0) 'first name
Case 2: GetNamePortion = arr2(1) 'middle name
Case 3: GetNamePortion = arr3(0) 'last name
Case 4: GetNamePortion = arr3(1) 'suffix, like Jr or III
End Select
End Function
For ex: Aquilio, III, John gives me results like this:
firstname - III
Middlename -
Lastname - Aquilio
Suffix -
I am expecting a result like this:
firstname - John
Middlename -
Lastname - Aquilio
Suffix - III
Thanks for any help.