Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / May 2008

Tip: Looking for answers? Try searching our database.

Working with tables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alimbilo - 21 May 2008 14:49 GMT
I need a formula to Sum the fields of a different table to a form that needs
those data.

Example:

Form name: Books
Table1 (field: total books)
Table2 (fields: old books, new books)

In the Books form, I want Total  Books from Table1 to be the Sum of table2
fields
Evi - 21 May 2008 15:29 GMT
Why do you want to store this value in a table? Each time you added or
deleted a book, the amount stored in your table would be wrong. Usually,
calculated amounts (values which can be obtained by a function like adding,
etc) are displayed using queries or reports or even text boxes in forms.
That way, they will always be up to date.

The exception to this rule would be when human intervention sets the rules
eg bulk-bought items where the more a customer buys, the less he has to pay
per unit. Since the formula for working out the discount might change at a
future date, you may need to store the current discount in some way.

The usual way to store calculations would be
1. In a report listing your books

In the report footer, you would add a text box into which you would type

=Count(OldBooks) + Count(NewBooks)

If you needed, for example, to add up these figures at the end of each week,
you would ensure that your database contained a date field and then using
the Sorting Grouping feature to do this.

2. In a  query.
You would create 1 query where you add a column which says

Books::[OldBooks]+[NewBooks].
Save and close this query

Click on it, in the database window, go to Insert Query.
Add the Books field to the query grid
Click the Totals button and choose Count

The query would give you the total numbers of books.

Refinements can be made to this so that you have the totals for each
day/week/year.

If you for some reason you do need to store the value in a table then, you
would do this by using Code to run an append or update query. You would then
need additional code if someone added or deleted a book, otherwise the
stored amount would be incorrect.
But before you start learning how to do this, just check your database
design  to see if you need it.

Evi

> I need a formula to Sum the fields of a different table to a form that needs
> those data.
[quoted text clipped - 7 lines]
> In the Books form, I want Total  Books from Table1 to be the Sum of table2
> fields
Beetle - 21 May 2008 15:44 GMT
> In the Books form, I want Total  Books from Table1 to be the Sum of table2
> fields

No you don't (not in the table at least). Calculated results like this
should not
be stored in tables. Do the calculation in a query, or in an unbound control
on a form or report.

While were on the subject, I don't know anything about your db, but I would
question whether you need the "old books" / "new books" fields in Table2
(assuming that those fields store the quantity of old and new books, which
is how it would appear on the surface). If you store info about books, and if
you have some type of "category" field to classify books as old or new, then
again, you can use a query to determine the quantity of old vs. new.

Signature

_________

Sean Bailey

> I need a formula to Sum the fields of a different table to a form that needs
> those data.
[quoted text clipped - 7 lines]
> In the Books form, I want Total  Books from Table1 to be the Sum of table2
> fields
Stockwell43 - 21 May 2008 16:01 GMT
Hi Alimbilo,

Evi is correct in the fact that you should not save information in the
table. However, you can calculate your fields on the form which would be fine
but again, if you need to view this information for multiple records, you
will need to create a report and insert the calculation there as Evi
explained.

To calculate on your form:

In your totals text box (make sure it is not bound to the table) In the
Control Source type =[NewBooks]+[OldBooks] (or whenever your field names are)
and that should do it.

> I need a formula to Sum the fields of a different table to a form that needs
> those data.
[quoted text clipped - 7 lines]
> In the Books form, I want Total  Books from Table1 to be the Sum of table2
> fields
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.