How to Split First Name and Last Name from Full Name




How to Split First Name and Last Name from Full Name

Sometime we have only one field for a full customer name, do not have a separate field for first name and last name. In the picture below, it is a list of customer full name.

customer name

If we want to extract a first name and last name from this full name of customer name, we can use the Left Function and Mid Function with InStr function inside the Left and Mid Function. We can create a new field for FirstName and LastName in the query by using Left and Mid function as shown in the picture below.
query for firstnameget firstname and lastname

Note:

Left Function: Returns a Variant (String) containing a specified number of characters from the left side of a string. Syntax : Left (anystring, number of character from the left side of string)
This example uses the Left function to return a specified number of characters from the left side of a string.

Dim strText, MyStr
 strText = "Hello World" ' Define string.
 MyStr = Left(strText, 1) ' Returns "H".
 MyStr = Left(strText, 7) ' Returns "Hello W".

More Info about Left function at: https://support.office.com/en-za/article/Left-Function-d5897bf6-91f5-4bf8-853a-b63d7de09681

InStr Function: Returns a Variant (Long) specifying the position of the first occurrence of one string within another.

More Info about InStr function at : https://support.office.com/en-us/article/InStr-Function-85D3392C-3B1C-4232-BB18-77CD0CB8A55B

Mid Function: Returns a Variant (String) containing a specified number of characters from a string.
More info about Mid Function at : https://support.office.com/en-sg/article/Mid-Function-427e6895-822c-44ee-b34a-564a28f2532c

Related posts