0

all i want is change all the record in my table if the pcarrier="Credit" but my problem is only one data have been changes. .

Set rs = New ADODB.Recordset
rs.Open "Select * from Soldto where cno='" & Combo1.Text & "'", cn, adOpenKeyset, adLockPessimistic
If rs!pcarrier = "Credit" Then
Do Until rs.EOF
rs!pcarrier = "Paid"
rs.MoveNext
rs.Update
Loop
End If

help thanks. .

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by vb5prgrmr
0

Try something like...

If rs.BOF = False AND rs.EOF = False AND rs.RecordCount <> 0 Then
  rs.MoveFirst
  Do While Not Rs.EOF
    rs.Edit
    rs!pcarrier = "Paid"
    rs.Update
    rs.MoveNext
  Loop
End If
0

a single update statement will do , why you need a loop for that.

I agree, but original poster is using loop and I am trying to help them with the logic of the loop and as to why only one of multiple records are being updated.

0

that ok, but updating records in a loop is not recommended as it takes a lot of system resources. and you have to commit very frequently , which again has a lot of side effects.

0

True, but look at the logic originally used. Just trying to get poster to think about their logic...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.