Solved

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

Posted on 2010-09-08
11
316 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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now