How to add calculated field to forms

  • Thread starter Thread starter Jack
  • Start date Start date
Jack said:
I wold like to add a calculated field to a master/sub form. I would like to put a calculated field on the master that will give me the sum of Amount due and Amount received fields on the sub form. And will update when I enter a new or change a record on the sub form.
 
I wold like to add a calculated field to a master/sub form.

Create a new textbox on the form.
Set its Control Source to

=[txtX] + [txtY]

or whatever calculation you want to use.

Your question is awfully vague, so you're getting an awfully vague answer.
 
Put text boxes in the footer of your *subform* that
will total the values you want using a Control Source
like =Sum([SomeField]). Make them hidden if you
don't want the users to see them there.

Then put text boxes in your main form which will
refer to the text boxes in your subforms footer. Use
a Control Source like;

=[SubformControl].Form![txtSubTotal]

Where SubformControl is the name of the window that
holds the subform and txtSubTotal is the name of the
text box in the subforms footer. Keep in mind that the name
of the SubformControl may not necessarily be the same as
the name of the subform itself.
 
Thank you Beetle,
It works perfect. It gives the the info I want for each record and when I
leave the field in the subform it updates the information. Now all I have to
do is have it update it when I leave a field, but I am sure I can do that If
I play with the leave field command. What does the " ! " do? I don't think I
have ever used it in any other programing language. I would never have
thought you could put calculations in a text box, but it seems a good thing
that you can.
--
Thank you, Jack


Beetle said:
Put text boxes in the footer of your *subform* that
will total the values you want using a Control Source
like =Sum([SomeField]). Make them hidden if you
don't want the users to see them there.

Then put text boxes in your main form which will
refer to the text boxes in your subforms footer. Use
a Control Source like;

=[SubformControl].Form![txtSubTotal]

Where SubformControl is the name of the window that
holds the subform and txtSubTotal is the name of the
text box in the subforms footer. Keep in mind that the name
of the SubformControl may not necessarily be the same as
the name of the subform itself.

--
_________

Sean Bailey


 
Back
Top