Solved

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

Posted on 2010-09-08
11
320 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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