add 3 record fields to populate a 4th?

btappan

Registered User.
Local time
Today, 12:30
Joined
Feb 24, 2007
Messages
40
I have a table where there each record has 3 fields i need to add together for a fourth both in my form and the table and i need the data in that field to be uneditable. how might I accomplish this? In the control source i tried:

=[LINE 1 QUANTITY]+[LINE 2 QUANTITY]+[LINE 3 QUANTITY]

but it displays

#Name?
 
alright i was able to do it wit:
=Val([LINE 1 QUANTITY])+Val([LINE 2 QUANTITY])+Val([LINE 3 QUANTITY])

but I need this calculation to also be stored in the table.my other problem is that if any one of the 3 totaled fields are blank it says error and and also if all three fields are blank it says error, I need it to say "0"
 
No, you don't need to add up three fields to create the fourth field in your table. (Yes, that's right. I said you don't.) You don't need to store squat.

NEVER store a computed value when you could just write a query to recompute it when you need it. NEVER. (OK, hardly ever...) A table is a recordset. So is a query. Never send a table to do a query's job. Put anything computable in the query and open the query as though it were a recordset. With the understanding that you cannot update the computed fields. But if this is for display only, you won't do that, right?

The NZ function comes to mind as a possible solution to your second problem about blanks and zeros and such. Look that one up in Access Help.

The only exception to storing a computed value is when there is no record of the components of a computation, only of the end result. Like, in a store, when one discount is applied and the manager has to do a discount override in order to match another store's prices... ("WE WON'T BE UNDERSOLD!!!") So you would store that final discount because there is no other way to capture it - and it won't be in your database because the other store's discounts normally aren't. That's an example of how rare it is to break the "never store a computed result" rule.
 
well in my instance, the tallied values represent used parts and their condition. there might be 3 "like new" parts, 2 "rusty parts" and 4 "new in box parts" that all share the same part identification # for a total of 9 parts, this data will be exported to quickbooks which only supports a single number for qty. on hand , that being said, i beleive i need to store this data in the table since it is not just for my visual pleasure! any more help on this with that being said?
 
Your table is not normalized.

Parts is parts. One table. Add a "quality" field if you like on the Access side.

NEVER add and store anything you could have computed. And while you are at it, read up on normalization.

I'm not trying to be a hard-ass about this. There are REASONS we tell you things of this sort. We don't want you to put yourself in the mind set that uses denormalized data. You end up with crappy designs that become more and more difficult to manage as the layers of code get thicker. You don't want that. We don't want it for you. Call it "tough love" if you like. But you don't want to do what you say you are doing. REALLY, you don't.

By the way, you CAN create a query that totals your three fields to create a computed fourth field. AND -... a query is exportable, too!
 

Users who are viewing this thread

Back
Top Bottom