Calculation from a subform

  • Thread starter Thread starter Secret Squirrel
  • Start date Start date
S

Secret Squirrel

I'm trying to create a calculation that includes 1 field from my main form.
The calculation will be put on the subform. This is what I have for a formula
in the control source field:

=(Forms!PSHourlyRate!HourlyRate1-[TotalCost])/[TotalCost]

It doesn't seem to be working. Am I missing something with the way this
formula is set up?
 
Secret Squirrel said:
I'm trying to create a calculation that includes 1 field from my main
form.
The calculation will be put on the subform. This is what I have for a
formula
in the control source field:

=(Forms!PSHourlyRate!HourlyRate1-[TotalCost])/[TotalCost]

It doesn't seem to be working. Am I missing something with the way this
formula is set up?
 
It would probably be wise to first make sure you can get the value of the
mainform into the subform before proceeding with a calculation;

the syntax I would try is: Forms!MainFormName.ControlName

the shortcut often works: Me.Parent.ControlName
 
Hi

It depends where your calculted box is

If it's on the main from
=Nz(SubformName.Form!ControlName,0)+Nz([MainFormControl],0)

If it's on the subform
=Nz([Forms]![MainFormName]![MainFormControl],0)+Nz([SubformControl],0)
 
Hi

It depends where your calculated box is as you need to refer to the form and
then the control like this

If it's on the main from
=Nz(SubformName.Form!ControlName,0)+Nz([MainFormControl],0)

If it's on the subform
=Nz([Forms]![MainFormName]![MainFormControl],0)+Nz([SubformControl],0)

In your case

=(Forms!PSHourlyRate!HourlyRate1-[TotalCost])/[TotalCost]
I’m not sure how you are getting [TotalCost], is this the name of a control
? or is it something else
Also are you sure that all the controls have a value (ie. You are not using
Nz)
 
Is this the control source for a control on the subform? If so, where is
this control on the subform (footer)?

Assuming that [HourlyRate1] is field in the main forms record source, try:

= (me.parent.HourlyRate1 - [TotalCost])/[TotalCost]

HTH
Dale
 
Secret,

Is this control on the subform? Is this control in the subforms footer?

Is HourlyRate1 a field in your main forms record source?

If so, try:

= (me.parent.HourlyRate1 - [TotalCost])/[TotalCost]

HTH
Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top