Sie sind auf Seite 1von 1

Modificar un Registro

Private Sub ChameleonBtn2_Click()

'Abre el formulario para Editar el registro seleccionado en el ListView


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim i As Integer

' verifica que hay datos en el ListView y que hay uno seleccionado

If (LV.ListItems.Count = 0) Then
MsgBox "No hay ningún regisro para editar", vbInformation
Exit Sub
End If
If (LV.SelectedItem Is Nothing) Then
MsgBox "Debe seleccionar previamente un registro para poder editarlo",
vbInformation
Exit Sub
End If

With FrmAM
' obtiene el elemento seleccionado
.lblID = LV.SelectedItem.Text
For i = 1 To 4
.Text1(i).Text = LV.SelectedItem.ListSubItems(i).Text
Next
.CmbSexo = LV.SelectedItem.ListSubItems(5).Text
.lblFecha = LV.SelectedItem.ListSubItems(6).Text
.IdRegistro = LV.SelectedItem.Text
.ACCION = 0

.Show vbModal
End With

End Sub

Bloque de código a agregar en el case del FrmAM


para modificar un registro
Case 0

cnn.Execute "UPDATE Personas set Nombre = '" & Text1(1) & _


"', Apellido = '" & Text1(2) & _
"', Telefono = '" & Text1(3) & _
"', Direccion = '" & Text1(4) & _
"', Sexo = '" & CmbSexo.ListIndex & _
"' where Id = " & IdRegistro & ""

Das könnte Ihnen auch gefallen