By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,651 Members | 1,694 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,651 IT Pros & Developers. It's quick & easy.

Sum to be able to be viewed on a Report!

P: 51
I have a text box [txttotalmatcost] with the following in the control source

=CDbl(nz([txtmatcost1],0))+CDbl(nz([txtmatcost2],0))+CDbl(nz([txtmatcost3],0))+CDbl(nz([txtmatcost4],0))+CDbl(nz([txtmatcost5],0))+CDbl(nz([txtmatcost6],0))+CDbl(nz([txtmatcost7],0))+CDbl(nz([txtmatcost8],0))+CDbl(nz([txtmatcost9],0))+CDbl(nz([txtmatcost10],0))

This works well for the sum of above text boxes.
However it is not bound to the txt box - I put it in the control source

What I want to do is bound the text box so I can easily bring up the sum so I can use the answer in various reports.

1st question is this the proper way to do this? or should it be done in a query?
2nd question if it is - where do I input the above and how?

Summary of what I am looking for is to have the sum of the text boxes to be able to be viewed on a report.

Thanks for your direction
Gary
Nov 16 '08 #1
Share this Question
Share on Google+
2 Replies


Expert Mod 2.5K+
P: 2,545
Hi. Binding is not really what you mean here - a bound control is one which is bound to an underlying field in a table. It is not normal practice to store computed values in a table - these should be computed on demand, using a query to do so.

You do need to be clear, however, that whilst you are summing textbox control values at the moment these are just a means of displaying data on a form. It is the fields of the underlying query or table to which the textboxes are bound which should be summed, not the textbox values themselves. That way you are not dependent on the form being open at the time you do the computation.

My advice therefore would be to add the computation as an additional computed field with a suitable name to whatever query you currently use as the source for your form. You will then have an up-to-date summed value available every time you run the query.

The computed field is entered into a blank column in the Access query editor as something like this:

Expand|Select|Wrap|Line Numbers
  1. Summary Total: CDbl(Nz([firstfield], 0)) + CDbl(Nz([secondfield], 0)) ... CDbl(Nz([Lastfield], 0))
Equivalently, in SQL this is just

Expand|Select|Wrap|Line Numbers
  1. Select <your existing fields>, CDbl(Nz([firstfield], 0)) + CDbl(Nz([secondfield], 0)) ... CDbl(Nz([Lastfield], 0)) As [Summary Total]
  2. FROM <name of your query or table>...
-Stewart
Nov 16 '08 #2

P: 51
Thanks Stewart for your reply.
Makes sense and the answer I expected. Did what you suggested and worked well.
Thanks for your help
Gary
Nov 20 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.