How to use ADO to Update multiple records (1 Viewer)

Moore71

DEVELOPER
Local time
Today, 14:17
Joined
Jul 14, 2012
Messages
158
Hi,
I am just worried how to update multiple record using ADO since when I used DAO, update is possible with few records, but when the records gets to 50 or more, error rises.
Here is the code I used:

"Dim RS As DAO.Recordset

Set RS = Me.RecordsetClone

With RS
.MoveFirst
Do While Not .EOF

'If RS.EOF Then

.Edit

RS("QtyAvail") = RS("QtyAvail") + RS("QtyIn")

RS("UnitCost") = RS("ExtendedPrice")

RS("SupplierAcc") = RS("SupplierAcc") - RS("AmountRecorded")

.Update

'End If

.MoveNext

Loop

.Close

End With

Set RS = Nothing"

So tell me what is wrong here!

Thanks for your response
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:17
Joined
Feb 19, 2013
Messages
16,607
for one thing, your code is not indented so makes it difficult to read. It would also help if you expanded on 'but when the records gets to 50 or more, error rises' - what error?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 23:17
Joined
Jan 20, 2009
Messages
12,851
The error is probably data related. Have a look at the record where it breaks.
 

jdraw

Super Moderator
Staff member
Local time
Today, 09:17
Joined
Jan 23, 2006
Messages
15,379
Moore71,

When you copy and post code use code tags.
--click the Go Advanced button
--notice the # in the symbols above the post window
--highlight your vba/sql code and then click the #

--it is also helpful if you indent your code to improve readability
--it is important that you show all the code from Sub/Function to
End Sub/End Function


example:
Code:
Sub showRelationsforTable()
    ShowRelations ("tblagency")
End Sub

Good luck.
 
Last edited:

Users who are viewing this thread

Top Bottom