Adding subbtotals to Table - Please Help!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sorry if this is a stupid question but I am real newby.

Here is the problem. I am working on a "simple" databese which has a few
simle plus and minus operations.
I made a form that enters values in the table. I have couple of numbers that
I write in the form and I need them to show subtotal in a form (i know how to
do this part), but also I need that this subtotal goes to one of the table
cells.
Something like this: cell 1: number 01, cell 2: number 02, cell 3: subtotal
of cell 1 an 2.
Maybe this is a stupid question but I realy don't know how.
 
hi,
storing total and subtotal in a table is not wise. why? if the underlying
data changes, this will not change the totals/subtotals.
it is wiser, to calculate the totals/subtotals in a report or query.
to calculate the subtotals in a query do this....
in query design view, add your table. drag the fields that you want to
subtotal.
from your example it would be number1 , number2
then in the third header put this
SubTotal:[Number1]+[Number2]
you could save the query with name qrySubTotals
you could then put a button on your form with caption subtotals
behind the buttton you could put this...

Sub ShowST_Click()
DoCmd.OpenQuery "qrySubTotals", acviewnormal
end sub

that's the best advice i can give.

Good luck.
FSt1
 
Sorry if this is a stupid question but I am real newby.

Here is the problem. I am working on a "simple" databese which has a few
simle plus and minus operations.
I made a form that enters values in the table. I have couple of numbers that
I write in the form and I need them to show subtotal in a form (i know how to
do this part), but also I need that this subtotal goes to one of the table
cells.
Something like this: cell 1: number 01, cell 2: number 02, cell 3: subtotal
of cell 1 an 2.
Maybe this is a stupid question but I realy don't know how.

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

You can just use fields (Access doesn't use "cells", it's not a
spreadsheet) 1 and 2 in your table, and create a Query selecting those
two fields; in a vacant Field cell in the query type

Subtotal: [Field1] + [Field2]

You can then use this Query as the recordsource for a form or report;
the subtotal will be recalculated whenever it's needed.

John W. Vinson[MVP]
 
Thanks guys,
probably I'll do this instead, but still I wold like to know how to create
subtotals in tables directly.

jw
 
Back
Top