Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/01/2009, 07:46
Lalybs
 
Fecha de Ingreso: diciembre-2008
Ubicación: Gral. Roca - Río Negro
Mensajes: 34
Antigüedad: 15 años, 5 meses
Puntos: 1
Mensaje Eliminar último Registro de un flex

Buenas, tengo el siguiente código para eliminar registros de una tabla "Categorias" pero el problema está cuando quiero eliminar el último registro, me sale el siguiente error: No se puede eliminar el último registro de la tabla.. si alguien me puede ayudar por favor.. Gracias


Private Sub BorrarFilas()
' Borrar las filas seleccionadas
Dim i As Long
Dim j As Long
Dim k As Long
Dim n As Long
Dim rc As New ADODB.Recordset

With lista
If lista.Row <= 0 Then
MsgBox "No hay ninguna fila seleccionada para eliminar", vbExclamation
Exit Sub
End If


sql = "DELETE FROM categorias where plu =" & lista.TextMatrix(lista.Row, 0)
rc.Open sql, con, adOpenKeyset, adLockOptimistic, adCmdText

i = lista.Row
j = lista.RowSel
If i < j Then
k = i
i = j
j = k
End If
For n = i To j Step -1
lista.RemoveItem n
Next
LastRow = lista.Rows - 1
LastCol = 1
lista.Col = LastCol
lista.Row = LastRow
lista.RowSel = LastRow
lista.ColSel = LastCol
listar
End With

End Sub