Southperry.net
Recordset.edit in a Loop (VB6 DAO) - Printable Version

+- Southperry.net (https://www.southperry.net)
+-- Forum: Social (https://www.southperry.net/forumdisplay.php?fid=14)
+--- Forum: Rubik's Cube (https://www.southperry.net/forumdisplay.php?fid=58)
+--- Thread: Recordset.edit in a Loop (VB6 DAO) (/showthread.php?tid=47834)



Recordset.edit in a Loop (VB6 DAO) - FenixR - 2011-10-12

Code:
Dim R As Integer
        Dim C As Integer
        C = 0
        R = 1
Do Until C = FGfac.Rows - 1
If cmdagregar.Enabled = True Then
        RST.AddNew
Else
        RST.Edit
If Not C = 0 Then
        RST.MoveNext
End If
End If
        RST![N° Factura] = txtnumfactura
        RST![Codigo Producto] = FGfac.TextMatrix(R, 0)
        RST![Cantidad Producto] = FGfac.TextMatrix(R, 2)
        C = C + 1
        R = R + 1
If C = FGfac.Rows - 1 Or cmdagregar.Enabled = True Then
        RST.Update
End If
        Loop

Sadly doing it like this only loops once before going error code "Update or CancelUpdate without addnew or edit" on me Rolleyes

Someone knows of a way to make it Edit all the records and not just only the first one? (Btw .AddNew Works like a charm, its .Edit that im having a problem with)


Recordset.edit in a Loop (VB6 DAO) - FenixR - 2011-10-12

Hate Myself for doing a thread out of this, The Solution:
Code:
Dim R As Integer
        Dim C As Integer
        C = 0
        R = 1
        Do Until C = FGfac.Rows - 1
        If cmdagregar.Enabled = True Then
        RST.AddNew
        Else
        RST.Edit
        End If
        RST![N° Factura] = txtnumfactura
        RST![Codigo Producto] = FGfac.TextMatrix(R, 0)
        RST![Cantidad Producto] = FGfac.TextMatrix(R, 2)
        C = C + 1
        R = R + 1
        RST.Update
If cmdagregar.Enabled = False Then
        RST.MoveNext
End If
        Loop
RST.Close

Works like a charm now


Recordset.edit in a Loop (VB6 DAO) - Spaz - 2011-10-12

My condolences for having to work with that language.