Locked lesson.
About this lesson
Learn calculation to Sum Field in Group Footer/Header, Page Header/Footer, or Report Header/Footer and calculation to get percent of a total in another control.
Exercise files
Download this lesson’s related exercise files.
Services_27_Start Calculated Controls and Control Names.accdb1.6 MB Services_27_Calculated Controls and Control Names.accdb
1.6 MB
Quick reference
Calculated Controls and Control Names
Application Terminology
Calculated Control
Any control with a Control Source can be a Calculated Control. Calculated Controls cannot be edited because they are bound to the expression in the control Source. Calculated Controls can be used on Forms and Reports.
The most common type of control to use for a calculation is a textbox.
The Control Source for a Calculated Control starts with =
Concatenate
Concatenate is a fancy term meaning to combine. For instance, this equation might go into a group footer for customer to show the number of records for that customer:
="Summary for " & [Customer] & " (" & Count(*) & " records)"
Control Name
It is always a good idea to give controls a logical Name as this is how values will be referred to in calculated controls and by code.
Steps
Calculation to Sum Field in Group Footer/Header, Page Header/Footer, or Report Header/Footer
- Create a textbox control
- Set the Name property to SumFieldnameQualifier
WHERE
Fieldname is the Fieldname you are summing
Qualifier is something to specify the section that the calculation is in, or some other way to distinguish it if it is used in other places
- Set the Control Source property to
=Sum([Fieldname])
- The same equation can be used in different sections. Access will calculate it right.
Calculation to Get Percent of a Total in Another Control
- Create a textbox control
- Set the Name property to PercentFieldQualifier
WHERE
Field is the Fieldname you are summing
Qualifier is something to differentiate this control from a control in another section
- Set the Control Source property to
=[Controlname1]/[Controlname2]
WHERE
Controlname1 is the name of a control with a calculation (or an expression)
Controlname2 is the name of a control with a calculation (or an expression)
- Set the Format property to Percent
- Set the Decimal Places property to whatever you like
Show the Number of Records in a Section
- Create a textbox control
- Set the Name property to something logical, especially if this control will be used in another calculation
- Set the Control Source property to
=Count(*)
Lesson notes are only available for subscribers.