Hi, I'm trying to display a calculation (in a form) based on related fields, that are in a sub-form.
What is the best way of doing this?
Calculated text box (in Form)
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Calculated text box (in Form)
Do you want to refer to fields in the current record in the subform, or do you want to perform a calculation across all records in the subform, for example a sum?
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Calculated text box (in Form)
I thought I'd missed something out :)
The calculation will the Max (dmax???) of selected fields on related records in the sub-form.
I hope that makes sense
The calculation will the Max (dmax???) of selected fields on related records in the sub-form.
I hope that makes sense
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Calculated text box (in Form)
You have to perform the calculation in the subform itself. Let's say that you want to display the maximum of the Price field.
Add a text box txtMaxPrice to the header or footer of the subform.
Set its Control Source to the formula =Max([Price])
Set its Visible property to No (unless you'd like to see the value in the subform).
Next, create a text box on the main form.
Set its Control Source to the formula =[SubformName]![txtMaxPrice] where SubformName is the name of the subform as a control on the main form.
Add a text box txtMaxPrice to the header or footer of the subform.
Set its Control Source to the formula =Max([Price])
Set its Visible property to No (unless you'd like to see the value in the subform).
Next, create a text box on the main form.
Set its Control Source to the formula =[SubformName]![txtMaxPrice] where SubformName is the name of the subform as a control on the main form.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Calculated text box (in Form)
Thank you Hans, that's done the trick