Help me resolve that problem I want to edit all the records only that meets the condition. The problem I'm is that my codes bellow behaves as though there no condition hence it is editing all the records in the table.
Dim a As Boolean
rs.Open "SELECT* FROM pupils", con, adOpenKeyset, adLockOptimistic - 1
rs.MoveFirst
Do While Not rs.EOF
If rs!grade = Me.txtoldtxtgrade And rs!CLASS = Me.txtolclass And rs!years = Me.txtoldyear Then
a = True
Exit Do
Else
rs.MoveNext
End If
Loop
If a = True Then
rs!grade = Me.txtnewgrade
rs!CLASS = Me.txtnewclass
rs!years = Me.txtnewyear
rs.Update
rs.Close
MsgBox "Records update", vbInformation
Else
rs.Close
MsgBox "Sorry something went wrong record not edited"
End If
End Sub