|
-
Jun 27th, 2002, 11:04 AM
#1
Thread Starter
Frenzied Member
Updating a record
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
-
Jun 27th, 2002, 11:16 AM
#2
I am assuming that you have one row in your grid for every record in your resordset. I see you looping through your grid but I don't see you looping through your recordset. You seem to be assigning everything to the same record. You probably need a movefirst and movenext statement.
-
Jun 27th, 2002, 11:23 AM
#3
Thread Starter
Frenzied Member
Hey Zemp,
I have edited my code to include .moveFirst and .moveNext but I'm still getting the same error[Code]
Private Sub cmdUpdate_Click()
On Error GoTo err
adoQuoteDets.Recordset.MoveFirst
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
.MoveNext
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
-
Jun 27th, 2002, 11:35 AM
#4
Thread Starter
Frenzied Member
-
Jun 27th, 2002, 11:49 AM
#5
Sorry for the delay, I don't stay on continually. Usually check back every couple of hours.
Beyond that i don't know. But I found this article with a quick search on MSDN. It might help.
http://support.microsoft.com/directo...EN-US;Q269379&
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|