?
Solved

Calculate percentage

Posted on 2007-07-26
4
Medium Priority
?
403 Views
Last Modified: 2008-02-01
Hello,

I have a table "tbl2007_conference" with three fields, "NumberAttendees", "PresenterRating1" and "PresenterRating1_perc"

I'd like the percentage (PresenterRating1/NumberAttendees x 100) to be automatically calculated in the "PresenterRating1_perc" field. Any help would be greatly appreciated.

Thanks!
0
Comment
Question by:p_classic_2000
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 19576412
Suggestion - not recommend to store calculated fields in table as you can always recalculate easily on forms

do u want to update values in table or sql?
if in sql do this

update tbl2007_conference set PresenterRating1_perc = PresenterRating1/(NumberAttendees * 100)

if in form, use the afterupdate events of PresenterRating1 and NumberAttendees  to do calculation
0
 
LVL 61

Expert Comment

by:mbizup
ID: 19576442
You should use queries to calculate and display data like this, rater than storing calculated data in your table.

SELECT *,   iif(NZ(NumerAttendees,0) = 0 , 0 ,100 * PresenterRating1/NumberAttendees) as PresenterRating1_perc
From tbl2007_conference

The iif should prevent divide-by-zero errors if NumberAttendees is 0.
0
 

Author Comment

by:p_classic_2000
ID: 19576674
Perfect, thanks rockiroads!
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 19576682
no probs
do think about not storing calculated values though, it may sound easy now but its more hassle than its worth
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

839 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