Solved

Increase number in table cell by percentage & round to nearest decimal.

Posted on 2010-09-08
11
317 Views
Last Modified: 2013-11-27
I have an access table that has a column of job rate.   Ex: 4.2516.      They need all the numbers (in the cells) in this column increased by  2.06% .   So the example would now be 4.3392   (they want it still to be rounded to the 4th decimal place.)

I know mathwise, it is (X * 1.0206) but am unsure how to apply this formula to all the cells in the column
0
Comment
Question by:czaz
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 33627284
UPDATE [SomeTable]
SET [job rate] = Round([job rate] * 1.0206, 4)

or, unrounded:

UPDATE [SomeTable]
SET [job rate] = [job rate] * 1.0206
0
 
LVL 77

Expert Comment

by:peter57r
ID: 33627303
Well you really need to agree rounding rules with your users, otherwise you will have arguments about the 4 th DP values.

The datatype of the JobRate field is important.
If it is currency you can do..
Update tablename set [job rate] = 1.0206*[Job Rate]

However if it is a double, then you will have to round:
Update tablename set [job rate] = round(1.0206*[Job Rate],4)
0
 
LVL 1

Expert Comment

by:momo4kids
ID: 33627724
You can also update the cells using an update query.  It should look something like this....
UPDATE [Tablename] SET [Tablename].JobRate = Round([JobRate]*1.0206,4);
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Expert Comment

by:momo4kids
ID: 33627733
Sorry...Peter57r just gave that some answer....
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 33628101
Use CCur, it rounds to four decimals:

UPDATE
  [YourTable]
SET
  [JobRate] = CCur([JobRate] * 1.0206)

/gustav
0
 

Author Comment

by:czaz
ID: 33628613
Is is possible for updates in one database to effect other files??
I ran a script & it seems to have updated a field accross multiple files, even ones in archive?

How is this possible
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 33628777
If the table is attached (linked) from another database file, the source table gets updated.

/gustav
0
 

Author Comment

by:czaz
ID: 33628869
Is there a way to see what it is linked to?
0
 

Author Comment

by:czaz
ID: 33630448
I found where the file is linked to and was able to restore data.

They are altering their request.  They want updates based on a JobCode of 'R',  So the current request is if JobCode=R, update the JobRate datafield.

BTW: I am using Access 2003
0
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 33630639
How about:

UPDATE
  [YourTable]
SET
  [JobRate] = CCur([JobRate] * 1.0206)
WHERE
  JobCode = 'R'

/gustav
0
 

Author Closing Comment

by:czaz
ID: 33746884
Rounded as I wanted it to.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question