So the report has a *column* for each year?
And the column names are 2001, 2002, etc?
If so, you could add a text box to the Report Footer section, and give it
these properties:
Control Source =Sum([2001])
Name txtSum2001
Then you could show the percentage difference in another text box with
properties like this:
Control Source =([txtSum2002] - [txtSum2001]) / [txtSum2001]
Format Percent
Once it's working, you probably want to refine it to:
=IIf([txtSum2001]=0, Null, ([txtSum2002] - [txtSum2001]) / [txtSum2001])
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Cecil said:
Allen,
Thanks for your response, but unfortunately I have very little experience
with VBA code outside usiing recommendations of others. I know my way
around
Access 2003 pretty well and just cannot get over this hurdle. My report
which
is based on a simple query looks similar to this:
2001 2002 2003 2004
Occasions 20 25 23 24
Attendance 224 125 122 200
Paper Sales 1000 1500 1250 1350
The data is located in the Year footer. I would like to calculate the
percent change in each variable for each year. For example, the
calculation
for total yearly Attendance is =Sum([Persons Attending]). My calculation
for
percent change of course comes to zero as i don't know the perform this
type
of calculation whithin the footer... =(Sum([Persons
Attending])-Sum([Persons
Attending]))...
Your help is greatly appreciated.
Allen Browne said:
If you just want to compare the value for one year with the value in the
previous record, and you are comfortable with VBA code, you could do it
like
this:
a) Declare a variable in the General Declarations section of the report's
module (at the top, with the Option lines), e.g.:
Dim varAmount As Variant
b) Add some code to the Print event of the (Detail?) section to remember
the
value, e.g.:
varAmount = Me.[Text22]
c) Add some code to the Format event of the section to assign the
calculation result to an unbound text box, e.g.:
Me.[txtDiff] = ...
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
i have a report sectioned by year with number fields. I would like to
calculate percent difference of the number fields for each year.