How to subtract two values to give me a total and grand total

  • I 2nd, 3rd and 4th the access option. It's easier to manage and sends less data on the network.

  • I tried entering the values in access text box "Default value" but no worky.  This is the code I used.  Is there something more to it or am I missing something?  =Val([lobc])+Val([looc])

  • You mean in Data / control source?

  • Just tried that just after I send the reply and it worked.  Now I need how to get the totals going down instead of across. like totaling the the totals such as the totals where the values are in =Val([lobc])-Val([looc]).

  • Same concept...

              Column1               Column2            Subtotal for row

              text1                    text2               =val(text1) + val(text2)

              text3                    text4               =val(text3) + val(text4)

    Grand total for columns

    =val(text1) + val(text3)     =val(text2) + val(text4)

    so on, etc, etc.

  •  I got everything working but when there is no data I have #error in the totals field. Any ideas? Thanks!

  • Default all the text boxes that are not calculated to 0

  • On further inspection, you will probably have to set these values on the load event of the form like...

    Private Sub Form_Load()

        Text1.Value = 0

        Text2.Value = 0

    End Sub

  • Got everything woking perfectly.  You guys are the bomb!!

  • Yeah, this is the best forum that I've seen.  Quick responses and knowledgeable people = nice solutions.

  • HTH... even if it's just a grain of salt .

  • everything worked great except I can't pull the totals with a stored procedure. All the data that was inputed is in the table including the totals except for the grand totals at the bottom. Here is the script in the default value to grab the values. =Val([losav])+Val([dissav])+Val([bfsav])+Val([pfsav])+Val([adfsav])+Val([apfsav])+Val([yspsav])+Val([irsav])

  • Brian, you do not need to pull the totals. They can be recomputed from the data.

    Mike

  • Actually the script above is what I used to pull all the totals. Anything with sav at the end is a total of a particular row. How can I recompute the data without have a long string of script from each cell.

  • If you are using an Access form you can link each textbox to a value from the Db. When you load the cells (i.e. move to a new row) the total textboxes will re-compute the totals. I usually use a custom form created in VB but each textbox should have a lost focus event where you can place the code to compute the totals for your totals textboxes.  You should only save the base data to your db and manipulate this data with your select statement or client side as I suggested above.

    Mike

Viewing 15 posts - 16 through 30 (of 30 total)

You must be logged in to reply to this topic. Login to reply