Public Declare Sub InitCommonControls Lib "comctl32" ()
Public cnn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public ObjItem As ListItem
Sub Main()
On Error Resume Next
Call InitCommonControls
Err.Clear
Form4.Show
End Sub
Public Sub IniciarConexion()
With cnn
.CursorLocation = adUseClient
.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\datos.mdb" & ";Persist Security Info=False"
End With
End Sub
Public Sub CargarListView(LV As ListView, rs As ADODB.Recordset)
On Error GoTo ErrorSub
Dim i As Integer
LV.ListItems.Clear
If rs.RecordCount > 0 Then
While Not rs.EOF
Set ObjItem = LV.ListItems.Add(, , rs(0))
ObjItem.SubItems(1) = rs!Numero
ObjItem.SubItems(1) = rs!Nombre
ObjItem.SubItems(2) = rs!Apellido
ObjItem.SubItems(3) = rs!Direccion
ObjItem.SubItems(4) = rs!Observaciones
If Abs(rs!estado) = 0 Then
ObjItem.SubItems(6) = "Masculino"
Else
ObjItem.SubItems(6) = "Femenino"
End If
ObjItem.SubItems(7) = rs!Fecha
' siguiente registro
rs.MoveNext
Wend
End If
Call ForeColorColumn(&H8000&, 0, Form4.LV)
'Call ForeColorColumn(vbRed, 6, FrmPrincipal.LV)
Exit Sub
ErrorSub:
If Err.Number = 94 Then Resume Next
End Sub
Public Sub CargarListView1(LV1 As ListView, rs As ADODB.Recordset)
On Error GoTo ErrorSub
Dim o As Integer
LV1.ListItems.Clear
If rs.RecordCount > 0 Then
' recorre el recordset
While Not rs.EOF
' añade los datos
Set ObjItem = LV1.ListItems.Add(, , rs(0))
ObjItem.SubItems(1) = rs!CI
ObjItem.SubItems(1) = rs!Nombre
ObjItem.SubItems(2) = rs!Numero
ObjItem.SubItems(3) = rs!FechaD
ObjItem.SubItems(4) = rs!fechaP
rs.MoveNext
Wend
End If
Call ForeColorColumn(&H8000&, 0, Form4.LV)
'Call ForeColorColumn(vbRed, 6, FrmPrincipal.LV)
Exit Sub
ErrorSub:
If Err.Number = 94 Then Resume Next
End Sub







Mode Lineal
