
ayuda con grilla
Publicado por miguel (51 intervenciones) el 10/10/2006 20:14:29
bueno mi problema es el siguiente cuando quiero eliminar una fila en una grilla no puedo y me aparece que ( no se puede quitar la ultima fila no fila ) no entiedo lo que pasa miren les mando algo del codigo para que lo vean PORFA AYUDA GRACIAS
Private Sub Command5_Click()
Dim x As Long, i As Long
On Error Resume Next
If Text1.Text = "" Then
MsgBox "DEBE BUSCAR ANTES DE ELIMINAR", vbInformation
Text1.SetFocus
Exit Sub
End If
On Error GoTo E
If MsgBox("DESEA ELIMINAR ", vbYesNo + vbCritical, "ELIMINAR") = vbYes Then
For i = 1 To grd1.Rows - 1
grd1.Row = i
If grd1.TextMatrix(grd1.RowSel, grd1.ColSel) = Val(Trim(Text9.Text)) Then
'PREGUNTAR POR CONTENIDO DE CELDA
grd1.RemoveItem grd1.Row ' DESDE AQUI ME MANDA AL MENSAJE
End If
Next
Dim a As Integer, c As Integer ' ESTE LUGAR ES PARA SABER SI HAY DATO NO
a = 1
c = 0
If grd1.TextMatrix(a, c) <> "" Then
For x = 1 To grd1.Rows - 1
grd1.Row = x
to2 = to2 + 1
'PREGUNTAR POR CONTENIDO DE CELDA
With grd1
.Col = 0
.Text = to2
End With
Next
End If
coman.ActiveConnection = Conex
coman.CommandText = "DELETE * FROM caja_chica where cod_caja = " & Val(Trim(Text9.Text)) & " AND usuario ='" & Combo8.Text & "'"
coman.Execute
If txt_total = 0 Then
Else
txt_total = (txt_total)
txt_total = Format(txt_total, "##,##0")
End If
grd1.Refresh
E:
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical
Else
MsgBox "eliminacion exitosa", vbInformation
txt_num = txt_num - 1
des True
Limpiar
deshabilitar True
cmd_mod.Enabled = False
Command5.Enabled = False
txt_item = txt_item - 1
Set coman = Nothing
grd1.Enabled = True
Exit Sub
End If
Else
deshabilitar True
cmd_mod.Enabled = False
Command5.Enabled = False
Text1.SetFocus
grd1.Refresh
Exit Sub
End If
End Sub
Private Sub Command5_Click()
Dim x As Long, i As Long
On Error Resume Next
If Text1.Text = "" Then
MsgBox "DEBE BUSCAR ANTES DE ELIMINAR", vbInformation
Text1.SetFocus
Exit Sub
End If
On Error GoTo E
If MsgBox("DESEA ELIMINAR ", vbYesNo + vbCritical, "ELIMINAR") = vbYes Then
For i = 1 To grd1.Rows - 1
grd1.Row = i
If grd1.TextMatrix(grd1.RowSel, grd1.ColSel) = Val(Trim(Text9.Text)) Then
'PREGUNTAR POR CONTENIDO DE CELDA
grd1.RemoveItem grd1.Row ' DESDE AQUI ME MANDA AL MENSAJE
End If
Next
Dim a As Integer, c As Integer ' ESTE LUGAR ES PARA SABER SI HAY DATO NO
a = 1
c = 0
If grd1.TextMatrix(a, c) <> "" Then
For x = 1 To grd1.Rows - 1
grd1.Row = x
to2 = to2 + 1
'PREGUNTAR POR CONTENIDO DE CELDA
With grd1
.Col = 0
.Text = to2
End With
Next
End If
coman.ActiveConnection = Conex
coman.CommandText = "DELETE * FROM caja_chica where cod_caja = " & Val(Trim(Text9.Text)) & " AND usuario ='" & Combo8.Text & "'"
coman.Execute
If txt_total = 0 Then
Else
txt_total = (txt_total)
txt_total = Format(txt_total, "##,##0")
End If
grd1.Refresh
E:
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical
Else
MsgBox "eliminacion exitosa", vbInformation
txt_num = txt_num - 1
des True
Limpiar
deshabilitar True
cmd_mod.Enabled = False
Command5.Enabled = False
txt_item = txt_item - 1
Set coman = Nothing
grd1.Enabled = True
Exit Sub
End If
Else
deshabilitar True
cmd_mod.Enabled = False
Command5.Enabled = False
Text1.SetFocus
grd1.Refresh
Exit Sub
End If
End Sub
Valora esta pregunta


0