Calculate percentage


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.

Who is Participating?
rockiroadsConnect With a Mentor Commented:
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
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.
p_classic_2000Author Commented:
Perfect, thanks rockiroads!
no probs
do think about not storing calculated values though, it may sound easy now but its more hassle than its worth
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.