You should be able to do this calculation in a query; or the values should be
in the query to be able to do the calc in a control on the form.
Please post the SQL of your query. If you keep getting a prompt, it means
the field [cmbMonthlyAnnual1] (value) is not available to do the calc.
---
It looks like [cmbMonthlyAnnual1] is a combo box. In the query you could try:
TheTotal: Nz([incVAIncome],0)*Nz(Forms!MyForm.[cmbMonthlyAnnual1],0)
replacing "MyForm" with the name of the form [cmbMonthlyAnnual1] is on.
---
Another (better?) way if there is no relationship between the two fields,
would be to write a custom function to do the calculation. In the query you
would have a column like:
Expr1: GetIncomeCalc([EmpID], Year(Date())
And in a standard module, you would have a function something like:
Public Function GetIncomeCalc(pEmpID as Long, pYear as Integer) as Currency
Dim something
Dim SomethingElse
' Get the data from [incVAIncome] and [cmbMonthlyAnnual1]
' using recordsets or lookups
'return the amount
GetIncomeCalc = Nz(Income,0))* MonthlyAnnual
End Function
Of course, this is just an example. Your function would use your field &
table names (and be written correctly).
---
As a last resort, you might be able to use DLOOKUP() to get the values and
do the calc in the control in the report.
HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
robertm600635 said:
ok, I'm not quite getting it. what i want to do is display the calculated
value from:
= Val(Nz([incVAIncome],0))*[cmbMonthlyAnnual1]
into a field on a report. I get why I shouldn't store this value in a field.
I keep seeing that I should perform this calculation in a query. I tried
this but it prompts me for input (enter value for [cmbMonthlyAnnual1]). Is
there a way to get it to run the calculation and output the value to my
report with out being prompted for input?
Duane Hookom said:
You shouldn't normally store calculated values in tables. However, you can
add code in the form hosting your combo box like:
Me.txtNoNameGiven = Val(Nz([incVAIncome],0))*[cmbMonthlyAnnual1]
Call this code in the after update of the incVAIncome text box and the
cmbMonthlyAnnual1 combo box.
--
Duane Hookom
Microsoft Access MVP
robertm600635 said:
I want to store a calculated value from a text box into a field, this is the
expression that I am using in the text box.
=Val(Nz([incVAIncome],0))*[cmbMonthlyAnnual1]
How do I store the result into a field for later use in a report?