A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Getting a total in $



 
 
Thread Tools Display Modes
  #1  
Old March 21st, 2010, 03:34 PM posted to microsoft.public.access.tablesdbdesign
Rob H
external usenet poster
 
Posts: 35
Default Getting a total in $

I have a table with a Gross Sales field and a Total Costs field, there is a
third field called Net Sales. How can I create a function to take Gross
Sales minus Total Costs to populate the Net Sales field? All three are set
to currency.
Ads
  #2  
Old March 21st, 2010, 07:29 PM posted to microsoft.public.access.tablesdbdesign
Al Campagna[_2_]
external usenet poster
 
Posts: 1,462
Default Getting a total in $

Rob H,
In your table... you don't.
Since you have the GrossSales and the TotalCosts in your table, then you
can
always calculate NetSales "on the fly" in any form, query, or report.
= GrossSales - TotalCosts
As a general normalization rule... don't store any values in a table,
that can be
derived from data you already have.
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

"Rob H" wrote in message
...
I have a table with a Gross Sales field and a Total Costs field, there is a
third field called Net Sales. How can I create a function to take Gross
Sales minus Total Costs to populate the Net Sales field? All three are
set
to currency.



  #3  
Old March 21st, 2010, 08:39 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Getting a total in $

On Sun, 21 Mar 2010 08:34:01 -0700, Rob H
wrote:

I have a table with a Gross Sales field and a Total Costs field, there is a
third field called Net Sales. How can I create a function to take Gross
Sales minus Total Costs to populate the Net Sales field? All three are set
to currency.


You don't.

The net sales should SIMPLY NOT EXIST in your table.

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; you can do so in a Query by
putting an expression like

NetSales: [Gross Sales] - [Total Costs]

in a vacant Field cell in the query, or on a Form or Report by putting

=[Gross Sales] - [Total Costs]

as the Control Source of a textbox.
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2004-2018 OfficeFrustration.
The comments are property of their posters.