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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Math Functions

Status
Not open for further replies.

troix

Technical User
Jan 20, 2004
46
US
If I have say 6 fields Score 1, Score 2, Score 3, etc.

And then a 7th field "Total Score"

What is the steps needed to make total score = a sum of Score 1 through Score 6?

Thanks so much!
 
troix,

As I am just getting starting in this as well, I will offer that you place an unbound text box on your form. In that box you can do:

=[score1]+[score2]+[score3]+ etc etc

or

you can create a query that does the math for you and then point your unbound text box back to the query.

I hope that helps.

Tony
 
How would I get the number in the "unbound field" to appear in TOTAL?
 
I have renamed the "hidden added field" to "Hidden Total"
BUT I need that number to appear in the form AND the table under "Score Total
 
I looked in that thread, and tried this


Private Sub Total_AfterUpdate()
Me.Total= Me.TotalHidden
End Sub

It's not working.
 
It won't - you need to put the code in the After_Update
event of the Score6 field...

this way what happens is;

The hidden box calculates on the fly the total score when you enter a number in to the Score1 thru Score6 fields as this happens the Score6 After_Update event fires, reads the value in the Calctotscore field and sends it to the TotalScore Field

In my example just change the Calctotscore Fieldname to TotalHidden and TotalScore fieldname to Total to achieve the same effect.

G.
 
Okay I got it now!

I just had to put default 0 in the score boxes to see a running score. Thanks amillion!
 
Hi Troix,

When you write: ....but I need that number to appear in the form AND the table under "Score Total" you are unintentionally looking to create problems you don't want...

Basic rule in databases is to only enter a datum once.

Sooo, if say:
score1 = 1
score2 = 1
score3 = 1

Total score does not need to be recorded, you already know it - 3. It is the sum of the individual scores. I.E. the total is implicit in the data you have already entered and you should not re-enter it.

Instead, when you want to view or report the total, whether on your data entry form, or on a report, use an unbound textbox with a recordsource like =[score1]+[score2]+[score3]+ etc etc

Perhaps better yet go to something like =nz([score1],0)+ nz([score2],0)+ nz([score3],0)+ nz([score4],0) .....

The nz will get rid of any "nulls" that might goof up your sums - it makes your totalling expression just see the nulls as zeros.

Best,

C



C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top