Peforming a division calculation of a field in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form in access2007, that has a check box. If the box is checked I
want it to divide whatever is in the field named "current budget total" by
12. But I want the results to into the field called "monthly budget" which
is located in a subform. I added the check box and went event builder and
put the following syntax in:
[PMP_BUDGET_ACCT_DETAIL]![CURRENT_BUDGET_AMT]=
[PMP_BUDGET_ACCT]![CURR_BUDGET_TOTAL]/12
because even though it's a form I want it done at the table level, but I did
try the form level and got the same message.

the object doesn't contain the automation object'BUDGET_ACCT_DETAIL'
I am not sure what I need to do, please help.
 
If it is a checkbox it will have a value of true or false, so your code
should look something like the following;

If Me![NameOfYourCheckbox] = True Then

Me![PMP_BUDGET_ACCT_DETAIL]![CURRENT_BUDGET_AMT]=_
Me![CURR_BUDGET_TOTAL]/12

Else

code for whatever happens if checkbox is false

End If

You could put this code in the After_Update event of your check box. The Me
reference is an easier way to refer to the form that contains whatever
control you are coding for. It beats typing the whole form name everytime.

BTW - you should not try to store your calculation in the underlying table.
It should only appear in your form

HTH
 
I have a form in access2007, that has a check box. If the box is
checked I want it to divide whatever is in the field named
"current budget total" by 12. But I want the results to into the
field called "monthly budget" which is located in a subform. I
added the check box and went event builder and put the following
syntax in: [PMP_BUDGET_ACCT_DETAIL]![CURRENT_BUDGET_AMT]=
[PMP_BUDGET_ACCT]![CURR_BUDGET_TOTAL]/12
because even though it's a form I want it done at the table level,
but I did try the form level and got the same message.

the object doesn't contain the automation
object'BUDGET_ACCT_DETAIL' I am not sure what I need to do,
please help.

Reference to a control or field in a subform is not self-evident.

You need to refer to the mainform, then refer to the subform
control's name, then refer to the form in the subform control, then
the name of the control or field

Forms!MainFormName!subformControlName!Form!Field|Control.property.
You can abbreviate Forms!MainformName! to Me! if the code is in
Forms!MainformName's module.

Note also that subformControlName is probably different from the
name of the form in the control The name of the form in the subform
control is actually the Source Object.
..
 
Back
Top