Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform field calculation

Status
Not open for further replies.

jmob

Programmer
Jun 21, 2005
58
US
I am trying to calculate a percentage for each count into a field[percent] in a subform. I want to take the corresponding [count] and divide it by the sum of the [count] column within the subform.
ex: count is stored in the db, percent is not(its just a txtfield)
Count Percent(Generated)
6 60 %
3 30 %
1 10 %
 
In the SQL of you subform the calculated field should Be


Percent: [YourTableName]![Count]/DSum("[Count]","YourTableName")*100

if you replace YourTableName with the name of your table

The text box in your subform can then be bound to this field


Jimmy
 
I'm having some trouble with this code. It gave me an error(which i haven't been able to recreate to see what it said) , and a ?Name just appears in the percent field. I am using a continuous form that is linked to the parent form. The subform is based on a query from the parent form. Any ideas as to what could be wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top