Aqui tienes tres funciones que extraeN de un campo (de longitud 35 en este caso) y que contiene APELLIDOS Y NOMBRE en el formato (PEREZ PEREZ, ANTONIO)
En tu consulta pondrias
Nombre:SoloNombre([campo apellidos y nombre])
1APELLIDO:Apellido1([campo apellidos y nombre])
2APELLIDO:Apellido2([campo apellidos y nombre])
En tu caso si solo tienes un apellido, utilizas apellido2
Saludos desde Cádiz y espero te valga.
Function SOLONOMBRE(ApeNom As String) As String
Dim CAMPO As String
Dim l As Double
l = 0
For i = 35 To 1 Step -1
l = l + 1
If Mid(ApeNom, i, 1) = "," Then
CAMPO = Mid(ApeNom, i + 2, l - 1)
Exit For
End If
Next i
SOLONOMBRE = CAMPO
End Function
End Function
Function Apellido1(ApeNom As String) As String
Dim CAMPO As String
Dim l As Double
For i = 35 To 1 Step -1
If Mid(ApeNom, i, 1) = "," Then
For n = i - 1 To 1 Step -1
If Mid(ApeNom, n, 1) = " " Then
CAMPO = Mid(ApeNom, 1, n - 1)
Exit For
End If
Next n
Exit For
End If
Next i
Apellido1 = CAMPO
End Function
Function Apellido2(ApeNom As String) As String
Dim CAMPO As String
Dim l As Double
l = 0
n = 0
For i = 35 To 1 Step -1
If Mid(ApeNom, i, 1) = "," Then
For n = i - 1 To 1 Step -1
l = l + 1
If Mid(ApeNom, n, 1) = " " Then
CAMPO = Mid(ApeNom, n + 1, l - 1)
Exit For
End If
Next n
Exit For
End If
Next i
Apellido2 = CAMPO