ParsingLastNAme




Public Function MoveLastName(TeamLeader) As String
Dim i%, start%, n As String
'This section will determine the length of the string

For i = Len(Me.TeamLeader) To 1 Step -1
'TeamLeader is the field name

If Mid(Me.TeamLeader, i, 1) <> " " Then
start = i
Exit For
End If
Next i
'This section will determine if the string is empty

For i = start To 1 Step -1
If Mid(Me.TeamLeader, i, 1) = " " Then
start = i
Exit For
End If
Next i
'This section checks for a Jr.,

'you could add OR "SR." to the end of "JR."

#If 1 Then ' fix Jr. problem
If UCase(Mid(Me.TeamLeader, start + 1)) = "JR." Or _
UCase(Mid(Me.TeamLeader, start + 1)) = "SR." Then
For i = start - 1 To 1 Step -1
If Mid(Me.TeamLeader, i, 1) = " " Then
start = i
Exit For
End If
Next i
End If
#End If
'Moves the result to the field where you want

MoveLastName = Mid(TeamLeader, start + 1)
Me.LstName = MoveLastName
End Function











( parsinglastname.html )- by Paolo Puglisi - Modifica del 17/12/2023