Calculate percentage

Posted on 2007-07-26
Last Modified: 2008-02-01

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.

Question by:p_classic_2000
    LVL 65

    Accepted Solution

    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
    LVL 61

    Expert Comment

    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.

    Author Comment

    Perfect, thanks rockiroads!
    LVL 65

    Expert Comment

    no probs
    do think about not storing calculated values though, it may sound easy now but its more hassle than its worth

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
    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 …

    761 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

    13 Experts available now in Live!

    Get 1:1 Help Now