Making numbers show in database

L

lktx

I have created a form and have used the following to calculate my TOTAL:

=Nz([TOTAL PRICE1])+Nz([TOTAL PRICE2])+Nz([TOTAL PRICE3])+Nz([TOTAL
PRICE4])+Nz([TOTAL PRICE5])+Nz([TOTAL PRICE6])+Nz([TOTAL PRICE7])

It's working fine, however, because it is an equation, the result does not
show up in the database. Since I'm using the database for a query that
involves the field TOTAL, I need a real number to show up. HOW!?

Thanks
 
P

Philip Herlihy

lktx said:
I have created a form and have used the following to calculate my TOTAL:

=Nz([TOTAL PRICE1])+Nz([TOTAL PRICE2])+Nz([TOTAL PRICE3])+Nz([TOTAL
PRICE4])+Nz([TOTAL PRICE5])+Nz([TOTAL PRICE6])+Nz([TOTAL PRICE7])

It's working fine, however, because it is an equation, the result does not
show up in the database. Since I'm using the database for a query that
involves the field TOTAL, I need a real number to show up. HOW!?

Thanks

I think you've half got the right idea! You're calculating this Total
quantity on the fly from information in your database - this is fine.
However, it's a bad idea to try to store the result. What if one of the
components is changed? Your stored values will be inconsistent. If you
can calculate it in a form, then you can calculate it in a query
(although you'd need to include the 'value if null' argument: the zero
shown below).

Put in a cell in the query builder:

MyTotal:Nz([Total Price1],0) + (etc...)

I've avoided naming the expression Total, as it may (haven't tested) be
a reserved word which might cause problems. Try MyTotal first anyway!

HTH

Phil, London
 
L

lktx

Philip:

Thank you so much.

I must be doing this backward. I was filling the DB from the form and
having the form calculate my subtotals and totals for me. I was hoping that
the calculated totals from the form could show up in the DB.

I don't really have to worry about changes in information - and if there was
a change - say a price changes, I'd want it to reflect in the DB, the form
and the query.

If I understand, you are saying to fill the DB? (In which case, I'll have
to manually calculate everything which is what I was trying to avoid.)

Sorry - I'm probably being dense.



Philip Herlihy said:
lktx said:
I have created a form and have used the following to calculate my TOTAL:

=Nz([TOTAL PRICE1])+Nz([TOTAL PRICE2])+Nz([TOTAL PRICE3])+Nz([TOTAL
PRICE4])+Nz([TOTAL PRICE5])+Nz([TOTAL PRICE6])+Nz([TOTAL PRICE7])

It's working fine, however, because it is an equation, the result does not
show up in the database. Since I'm using the database for a query that
involves the field TOTAL, I need a real number to show up. HOW!?

Thanks

I think you've half got the right idea! You're calculating this Total
quantity on the fly from information in your database - this is fine.
However, it's a bad idea to try to store the result. What if one of the
components is changed? Your stored values will be inconsistent. If you
can calculate it in a form, then you can calculate it in a query
(although you'd need to include the 'value if null' argument: the zero
shown below).

Put in a cell in the query builder:

MyTotal:Nz([Total Price1],0) + (etc...)

I've avoided naming the expression Total, as it may (haven't tested) be
a reserved word which might cause problems. Try MyTotal first anyway!

HTH

Phil, London
 
P

Philip Herlihy

lktx said:
Philip:

Thank you so much.

I must be doing this backward. I was filling the DB from the form and
having the form calculate my subtotals and totals for me. I was hoping that
the calculated totals from the form could show up in the DB.

I don't really have to worry about changes in information - and if there was
a change - say a price changes, I'd want it to reflect in the DB, the form
and the query.

If I understand, you are saying to fill the DB? (In which case, I'll have
to manually calculate everything which is what I was trying to avoid.)

Sorry - I'm probably being dense.



Philip Herlihy said:
lktx said:
I have created a form and have used the following to calculate my TOTAL:

=Nz([TOTAL PRICE1])+Nz([TOTAL PRICE2])+Nz([TOTAL PRICE3])+Nz([TOTAL
PRICE4])+Nz([TOTAL PRICE5])+Nz([TOTAL PRICE6])+Nz([TOTAL PRICE7])

It's working fine, however, because it is an equation, the result does not
show up in the database. Since I'm using the database for a query that
involves the field TOTAL, I need a real number to show up. HOW!?

Thanks
I think you've half got the right idea! You're calculating this Total
quantity on the fly from information in your database - this is fine.
However, it's a bad idea to try to store the result. What if one of the
components is changed? Your stored values will be inconsistent. If you
can calculate it in a form, then you can calculate it in a query
(although you'd need to include the 'value if null' argument: the zero
shown below).

Put in a cell in the query builder:

MyTotal:Nz([Total Price1],0) + (etc...)

I've avoided naming the expression Total, as it may (haven't tested) be
a reserved word which might cause problems. Try MyTotal first anyway!

HTH

Phil, London

No, you're not being dense, and I should have focused more on the use of
your form for data entry. However, the principle holds true - if you
can derive a quantity from data already held, then you needn't, indeed
shouldn't store the derived value.

I'm not an expert in the way some contributors here undoubtedly are, but
this is how I'd approach it. I'd have a form for data entry which
allowed me to input the raw information. (From your description these
are already totals?) Once the data is safely in table(s) then you can
write a query which can do the calculations. When your data is refined
into multiple tables, which suits many situations, Access's various
wizards can make surprisingly good guesses about the grouping and
summarising you might want, and will ask you relevant questions. In a
single table you have to do it yourself but it's not that hard if you're
prepared to do a little reading. If you use "grouping" in queries you
can use the "aggregate" functions of Sum, Count, Average, and so on.
This is good for producing results from Columns. If you need to combine
"horizontally" (i.e. using more than one field) then you need to use
Expressions in the query. A very simple expression might be:
Combined:=[ThisField]+[ThatField]
.... which will give you an extra column output from your query called
Combined. The Expression Builder (Google for articles or videos) is a
great way to get good at this.

Then, you can use a suitable query as a basis for a form designed to
present the information as you'd like it, or for a report suitable for
printing. Reports have powerful grouping and summarising facilties. The
wizards are a great help getting started.

These might help:
http://office.microsoft.com/en-us/training/CR061829401033.aspx

Phil
 
P

Philip Herlihy

Richard said:
Just a side note here, MyTotal is a great suggestion. I was curious to see
if total was a jet or sql reserved word. It doesn't appear to be 97-2007.

http://office.microsoft.com/en-us/access/HA100306431033.aspx?pid=CH100621381033

-T
TABLE
TableDef, TableDefs
TableID
TEXT
TIME, TIMESTAMP
TOP
TRANSFORM
TRUE
Type

Richard

Just glad to know that I'm not the only one that can't remember them!
I'm not even sure if it would cause a problem in that context, but it
pays to be cautious...

Phil
 
L

lktx

Here is my specific dilemma. I work for a university and have a form they
supply me I must use for purchase orders. I automated the form using access
and as far as the form goes - it's all good. However, now I am trying to
keep better track of our budget by running the query of total budget, minus
purchases. Which means I need a total for each purchase order to subtract
from the budget. I can't think of a way around not having subtotals
(quantity * price) and the TOTAL of each PO in the DB to get the info into
the query. I know there' s a way to do this. I'm sure I'm just going at it
wrong. I'm thinking inside the box.
 
P

Philip Herlihy

lktx said:
Here is my specific dilemma. I work for a university and have a form they
supply me I must use for purchase orders. I automated the form using access
and as far as the form goes - it's all good. However, now I am trying to
keep better track of our budget by running the query of total budget, minus
purchases. Which means I need a total for each purchase order to subtract
from the budget. I can't think of a way around not having subtotals
(quantity * price) and the TOTAL of each PO in the DB to get the info into
the query. I know there' s a way to do this. I'm sure I'm just going at it
wrong. I'm thinking inside the box.
....

The key to any database design is to figure out first what you need to
store. If you can derive any value from other values which are stored
in the database (and won't change) then you don't need to store the
derived value. If you have quantity and price (and things like
discounts, shipping) then you can calculate the Total in a query.

I'm not sure you've got this. It's often a bad idea to compare Access
with Excel but in this case it could make sense.

If you have, in Excel, a column for Price, and one for Quantity, you'd
expect a third column, headed "cost" to contain a formula (same formula
in each cell), not a value - right? Just the same in a query. If you
have a field designated "Price" and another designated "Quantity", you
shouldn't store the calculation a further field. Instead, you'd write a
query which derived the Quantity from the other two values. You'd use
an Expression (aka "Calculated Field") to do this. Here's a useful
reference on the subject:

http://allenbrowne.com/casu-14.html

and another:

http://www.dummies.com/how-to/content/creating-a-calculated-field-with-access-2007.html

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top