Update records

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

Guest

A form shows a number of selected records which I want to update when the
user selects the update % (RPI)

Me.alrAmount = RoundToNearest(Me.amount * ((RPI / 100) + 1), 0.5, up)

How do I loop through all the records displayed and update the values please

Thanks
 
You can try this

Dim I As Integer
DoCmd.GoToRecord , , acFirst
For I = 1 To Me.RecordsetClone.RecordCount
Me.alrAmount = RoundToNearest(Me.amount * ((RPI / 100) + 1), 0.5, up)
DoCmd.GoToRecord , , acNext
Next I
DoCmd.GoToRecord , , acFirst
 
In second thought, if you are trying to save a calculated field in the table,
then don't do that, you'll have to maintain it all the time, and it cause
problems like, what if someone will update the records through the table and
not through the form.

In that case you can always acheive the same resault using a query

Select TableName.* , RoundToNearest(amount * ((RPI / 100) + 1), 0.5, up) As
alrAmount From TableName
 
Back
Top