Updating a Recordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am attempting to scan through a recordset, and for each row apply various If statements to determine the value of a field and update the same. I have no previous programming experience and from the literature available, have came up with the following solution, which only updates the first row, can anybody help

Dim R As DAO.Recordse
Set R = CurrentDb.OpenRecordset("Loan_Request"

Do Until R.EO
If [Field_Name] = "X" The
[Blank_Field] = "Y
Els
[Blank_Field] = "N
End I
R.MoveNex
Loo
 
you need a R.Update before the R.MoveNext

HTH
Jack Barton said:
I am attempting to scan through a recordset, and for each row apply
various If statements to determine the value of a field and update the same.
I have no previous programming experience and from the literature available,
have came up with the following solution, which only updates the first row,
can anybody help!
Dim R As DAO.Recordset
Set R = CurrentDb.OpenRecordset("Loan_Request")

Do Until R.EOF
If [Field_Name] = "X" Then
[Blank_Field] = "Y"
Else
[Blank_Field] = "N"
End If
R.MoveNext
Loop
 
If you want to use ADO, your update code would be
something like this:

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.LockType = adLockOptimistic
rst.Open "Loan_Request"
Do Until rst.EOF
With rst
!Blank_Field = iif(!Field_Name = "X", "Y", "N")
.Update
.MoveNext
End With
Loop

rst.Close
Set rst = Nothing


-----Original Message-----
you need a R.Update before the R.MoveNext

HTH
I am attempting to scan through a recordset, and for
each row apply
various If statements to determine the value of a field and update the same.
I have no previous programming experience and from the literature available,
have came up with the following solution, which only updates the first row,
can anybody help!
Dim R As DAO.Recordset
Set R = CurrentDb.OpenRecordset("Loan_Request")

Do Until R.EOF
If [Field_Name] = "X" Then
[Blank_Field] = "Y"
Else
[Blank_Field] = "N"
End If
R.MoveNext
Loop


.
 
Back
Top