Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function GetLastName()
' This function extracts the first part of a string that is "LastName, FirstName"
Dim strLast, strFirst, strString As String
Dim intStrPos As Integer
strString = "Jones, John"
'1 -- Search for the position of the "comma" delimiter.
intStrPos = InStr(1, strString, ",", vbTextCompare)
'2 -- Get the last name using a Left Trim
strLast = Left(strString, (InStr(1, strString, ",", vbTextCompare) - 1))
'3 -- Get the First name using a combination of Trim and Right Trim
strFirst = Trim(Right(strString, Len(strString) - (InStr(1, strString, ","))))
'4 -- see the results!
MsgBox "Original String: " & strString
MsgBox "Last Name: '" & strLast & "' First Name: '" & strFirst & "'"
End Function
First: Left([tableName].[FieldNameToTrim], (InStr(1, [tableName].[FieldNameToTrim], ",", vbTextCompare) - 1))