Inventory Program

  • Thread starter Thread starter HubbyMax
  • Start date Start date
H

HubbyMax

Another problem. I have several calculated fields on my Enter Products form.
I would like to have these calculations entered on the Products2 table but
they leave the corrasponding fields blank.

TotalValue = (([NuPrice] + [CuPrice] / 2) * [UnitsInStock]

This fills in the Total Value of Current Stock field on the form but does
transfer the result to the Products2 table.
 
HubbyMax,

Basically, it shouldn't! It is generally accepted that you should not
store calculated results. That said, if you really want to, you'll
need to either have an append query to add the result or add them to a
recordset in VBA.

David

Share what you know, learn what you don't
 
Only bound fields are stored to tables. You can either add the 'calculated'
fields to the table as hidden fields, and then use a 'BeforeUpdate' event to
set them to be the values of the corresponding unbound fields on the form,
or you can change the unbound fields on the form to be the fields from the
table, and then run code containing the calculations to update these fields
whenever data in the source fields change (e.g. NuPrice, CuPrice, or
UnitsInStock).
 
Thank you. I was able to get this working using your suggestions.

Daryl S said:
Only bound fields are stored to tables. You can either add the 'calculated'
fields to the table as hidden fields, and then use a 'BeforeUpdate' event to
set them to be the values of the corresponding unbound fields on the form,
or you can change the unbound fields on the form to be the fields from the
table, and then run code containing the calculations to update these fields
whenever data in the source fields change (e.g. NuPrice, CuPrice, or
UnitsInStock).


--
Daryl S


HubbyMax said:
Another problem. I have several calculated fields on my Enter Products form.
I would like to have these calculations entered on the Products2 table but
they leave the corrasponding fields blank.

TotalValue = (([NuPrice] + [CuPrice] / 2) * [UnitsInStock]

This fills in the Total Value of Current Stock field on the form but does
transfer the result to the Products2 table.
 
Back
Top