Calculation based on another calculation

  • Thread starter Thread starter T Smith
  • Start date Start date
T

T Smith

Very frustrated here. I know I am doing something wrong. Generally speaking
on a form-is there any way to have a calculation based on the result value
from another field rather than having to recreate the complete calculation
in each step.

Example: Form name [money]. Four fields: money![cost], money![markup],
money![tax] and money![total]

A user inputs the desired value in the [cost] field, then a macro computes
the value of [markup], [tax], and [total].

Currently I use a macro that uses "setvalue" to set the value of each
calculation thereby also saving the calculated value in the underlying
table.

The problem:

Unless I recreate the entire calculation in each step nothing works.Example-
the value of [tax] must be "(forms![money]![cost]*1.1)*.05"
is there a way for it to work like this:
"forms![money]![cost]+forms![markup]*.05" (markup having been previously
calculated using markup=forms![money]![cost]*.1)

Please help. Both of these methods may be totally wrong. What I want to
accomplish is calculate values on a form and save those values to the
underlying table. Which as most people know-by default calculated vales in a
form are not saved the to underlying table.

Thanks
 
If you use the full syntax, it should work the way you want:

(Forms!FormName!ControlName + Forms!FormName!ControlName)*.05
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

T Smith said:
Very frustrated here. I know I am doing something wrong. Generally speaking
on a form-is there any way to have a calculation based on the result value
from another field rather than having to recreate the complete calculation
in each step.

Example: Form name [money]. Four fields: money![cost], money![markup],
money![tax] and money![total]

A user inputs the desired value in the [cost] field, then a macro computes
the value of [markup], [tax], and [total].

Currently I use a macro that uses "setvalue" to set the value of each
calculation thereby also saving the calculated value in the underlying
table.

The problem:

Unless I recreate the entire calculation in each step nothing works.Example-
the value of [tax] must be "(forms![money]![cost]*1.1)*.05"
is there a way for it to work like this:
"forms![money]![cost]+forms![markup]*.05" (markup having been previously
calculated using markup=forms![money]![cost]*.1)

Please help. Both of these methods may be totally wrong. What I want to
accomplish is calculate values on a form and save those values to the
underlying table. Which as most people know-by default calculated vales in a
form are not saved the to underlying table.

Thanks
 
Thanks for the input

Have tried that from the beginning and it still doesn't work. Example: in
the macro-Setvalue forms![money]![markup] = forms![money]![cost]*.1
The next step in the macro-Setvalue
forms![money]![total]=(forms![money]![cost]+forms![markup])

This will fail-it will never compute the value of [total]

Any other help is greatly appreciated.
 
A second question. Why do I keep getting the G*DDAMN! "Type Mismatch" error
when I try to run the macro in design mode. This occurs despite the fact
that all the fields involved are listed as currency.

Thanks
 
Back
Top