Access - CONSULTA

 
Vista:

CONSULTA

Publicado por JULIOESCOBAR (21 intervenciones) el 23/08/2007 16:52:45
TENGO UN CAMPO CON LOS NOMBRES DE X PERSONAS PERO LOS SEPARA CON EL SIGNO DE $ Y LO QUE QUIERO ES SEPARARLOS, EJEMPLO

ESCOBAR$GAMBOA$JULIO CESAR

QUIERO HACER UNA CONSULTA QUE OBTENGA LOS DATOS DE ESTE CAMPO:
APELLIDO PATERNO, APELLIDO MATERNO Y NOMBRE(S)

GRACIAS DE ANTEMANO
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:CONSULTA

Publicado por 2PL2PL (62 intervenciones) el 23/08/2007 22:17:58
En Primer lugar decirte que escribir en mayúsculas es como ¡¡¡ GRITAR¡¡¡
Y ahora lo tuyo.
Create un modulo y mete estas tres funciones que he creado expresamente para tu caso.
Luego en la consulta pones lo siguiente:

NomprePropio:NOMBRE([aqui tu campo])
ApellidoPaterno:Apellido1([aqui tu campo])
ApellidoMaterno:Apellido2([aqui tu campo])

'La longitud del campo a ApeNom en este caso es 35

Function NOMBRE(ApeNom As String) As String
Dim CAMPO As String
Dim I As Integer
Dim L As Integer
L = 0
For I = 35 To 1 Step -1
L = L + 1
If Mid(ApeNom, I, 1) = "$" Then
CAMPO = Mid(ApeNom, I + 1, L - 1)
Exit For
End If
Next I
NOMBRE = CAMPO
End Function

Function Apellido1(ApeNom As String) As String
Dim CAMPO As String
Dim I As Integer
For I = 1 To 35
If Mid(ApeNom, I, 1) = "$" Then
CAMPO = Mid(ApeNom, 1, I - 1)
Exit For
End If
Next I
Apellido1 = CAMPO
End Function

Function Apellido2(ApeNom As String) As String
Dim CAMPO As String
Dim I As Integer
Dim L As Integer
Dim n As Integer
Dim M As Integer
L = 0
M = 0
For I = 1 To 35
L = L + 1
If Mid(ApeNom, I, 1) = "$" Then
L = L + 1
For n = L To 35
M = M + 1
If Mid(ApeNom, n, 1) = "$" Then
M = M - 1
CAMPO = Mid(ApeNom, L, M)
Exit For
End If
Next n
Exit For
End If
Next I
Apellido2 = CAMPO
End Function

Saludos y si te vale.....pon un mensaje "TEMA CERRADO"
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar