You are on page 1of 2

Option Explicit

Dim cn As New ADODB.Connection


Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim findlastname As String
Private Sub Combo1_Click()
If (Combo1.ListIndex = -1) Then
Combo1.ListIndex = -1
Else
findlastname = Combo1.ItemData(Combo1.ListIndex)
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
With cmd
.CommandText = "Select Cedula, Nombre & "" "" & Apellido_P as " & " juntar from
Maestro where Cedula LIKE '% " & findlastname & "%'"
End With
With rs
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open cmd
End With
Set Text1.DataSource = rs
Set Text2.DataSource = rs
Text1 = rs.Fields("juntar")
Text2 = rs.Fields("Cedula")
End If
End Sub
Private Sub Command1_Click()
Load menu
menu.Show
Unload Form4
End Sub
Private Sub Form_Load()
Set cn = Nothing
Set rs = Nothing
cn.CursorLocation = adUseClient
cn.Open "Provider =Microsoft.ACE.OLEDB.12.0;Data source = C:\Users\Ivan\Desktop\
vb.mdb;Persist Security Info=False"
With cmd
.ActiveConnection = cn
.CommandText = "select * From UA"
End With
With rs
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open cmd
End With
Set DataGrid1.DataSource = rs
' rs.Close
'Set cn = Nothing
'Set rs = Nothing

Set rs = New ADODB.Recordset


With cmd
.ActiveConnection = cn
.CommandText = "Select Cedula, Nombre &"" ""& Apellido_P as " & " juntar
From Maestro"
End With
With rs
' .CursorType = adOpenKeyset
' .LockType = adLockOptimistic
.Open cmd
End With
Do Until rs.EOF
Combo1.AddItem rs.Fields("juntar")
Combo1.ItemData(Combo1.NewIndex) = rs.Fields("Cedula")
rs.MoveNext
Loop

End Sub

You might also like