Calculated text box (in Form)

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Calculated text box (in Form)

Post by Egg 'n' Bacon »

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?

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Calculated text box (in Form)

Post by HansV »

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

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Calculated text box (in Form)

Post by Egg 'n' Bacon »

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

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Calculated text box (in Form)

Post by HansV »

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.
Best wishes,
Hans

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Calculated text box (in Form)

Post by Egg 'n' Bacon »

Thank you Hans, that's done the trick :cheers: