My grid is attached to a database via ADO. I need to be able to update the information in this grid. But I keep getting the following error:
Error -2147467259 Key column information is insufficient or incorrect. Too many rows were affected by update
This is my code:Code:Private Sub cmdUpdate_Click() On Error GoTo err For i = 0 To adoQuoteDets.Recordset.RecordCount - 1 With adoQuoteDets.Recordset .Fields("QuoteNo") = cboQuoteNo.Text .Fields("PartNumber") = grd.TextMatrix(i, 1) .Fields("Description") = grd.TextMatrix(i, 2) If IsNumeric(grd.TextMatrix(i, 3)) Then .Fields("Quantity") = grd.TextMatrix(i, 3) Else .Fields("Quantity") = "0" End If If Not IsNumeric(grd.TextMatrix(i, 4)) Then .Fields("UnitPrice") = "0" Else .Fields("UnitPrice") = grd.TextMatrix(i, 4) End If If Not IsNumeric(grd.TextMatrix(i, 5)) Then .Fields("LineTotal") = "0" Else .Fields("LineTotal") = grd.TextMatrix(i, 5) End If .Update End With Next i err: If err.Number <> 0 Then MsgBox "Error " & Str(err.Number) & " " & err.Description, vbCritical + vbOKOnly err.Clear End If End Sub




Reply With Quote