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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top