i have this code that when you enter and ID and press search, it brings the data correctly. But if you want to look for the surname and by ID, it does not bring nothing. I think i done wrong the else if statement, but can´t find the error yet.
'declarar las variables
Dim FindRow
Dim i As Integer
Dim cRow As String
'error block
On Error GoTo errHandler:
'Filtrar solo por Legajo
If Me.TextBox6 = "" Then
'Encontrar la fila con la data
cRow = Me.TextBox5.Value
Set FindRow = Hoja4.Range("A:A").Find(What:=cRow, LookIn:=xlValues)
'agregar los valores a las casillas correspondientes
Me.TextBox7.Value = FindRow
Me.TextBox8.Value = FindRow.Offset(0, 1)
Me.TextBox9.Value = FindRow.Offset(0, 2)
Me.TextBox10.Value = FindRow.Offset(0, 3)
Me.TextBox11.Value = FindRow.Offset(0, 4)
'Filtrar solo por Apellido
Else
If Me.TextBox6 = "" Then
'Encontrar la fila con la data
cRow = Me.TextBox6.Value
Set FindRow = Hoja4.Range("B:B").Find(What:=cRow, LookIn:=xlValues)
'agregar los valores a las casillas correspondientes
Me.TextBox7.Value = FindRow
Me.TextBox8.Value = FindRow.Offset(0, 1)
Me.TextBox9.Value = FindRow.Offset(0, 2)
Me.TextBox10.Value = FindRow.Offset(0, 3)
Me.TextBox11.Value = FindRow.Offset(0, 4)
End If
'error block
On Error GoTo 0
Exit Sub
errHandler:
MsgBox "Error! Verificar los datos ingresados, porque no son correctos!" & vbCrLf & Err.Description
End If
End Sub
Aucun commentaire:
Enregistrer un commentaire