
07/12/2012, 07:57
|
 | | | Fecha de Ingreso: mayo-2011 Ubicación: Clorinda
Mensajes: 15
Antigüedad: 13 años, 10 meses Puntos: 1 | |
Respuesta: Búsqueda de Personas en tabla MYSQL Private Sub txtbusqueda_Change()
txt = "select id_persona From clientes where apellido_cli like '%" & txtbusqueda.Text & "%' or numero_doc like '%" & txtbusqueda.Text & "%'"
If rs.State = 1 Then rs.Close
rs.Open txt, cn, adOpenStatic, adLockOptimistic
Dim txte
txte = "select id_persona as Cód, Apellido_cli as Apellido, nombre_cli as Nombre, numero_doc as DNI from clientes where apellido_cli like '%" & txtbusqueda.Text & "%' or numero_doc like '%" & txtbusqueda.Text & "%'"
If rs.State = 1 Then rs.Close
rs.Open txte, cn, adOpenStatic, adLockReadOnly
If rs.RecordCount >= 1 Then
Dim i
Dim j
grilla.Clear
With grilla
.Rows = rs.RecordCount + 1
.Cols = rs.Fields.Count + 1
For i = 1 To rs.Fields.Count
.Row = 0
.Col = i
.Text = rs.Fields(i - 1).Name
Next i
End With
With grilla
For i = 1 To rs.RecordCount
For j = 1 To rs.Fields.Count
.Row = i
.Col = j
.Text = rs.Fields(j - 1).Value
.RowSel = grilla.Row
Next j
rs.MoveNext
Next i
End With
rs.Close
Else
MsgBox "El Cliente no se encuentra registrado", vbInformation
End If
End Sub |