Is there a way to do this with Access?

  • Thread starter Thread starter john
  • Start date Start date
J

john

Access Gurus,
I'm trying to make a report in which each line somehow refrences the
line before it, as in this example:

MONTH SALES CHANGE FROM PREVIOUS MONTH
Jan $1000 n/a
Feb $1100 +10%
Mar $1210 +10%
Apr $968 -20%
....

I've searched all the groups and all the books I could find. Any
ideas?
Thanks in advance!
-j
 
Use the form's events to achieve this.

1. Open the module of the report.

2. In the General Declarations section (top, under "Option..."):
Dim mvarPriorSales As Variant

3. In the Print event procedure of the Detail section:
If mvarPriorSales = 0 Then
Me.txtChange = Null
Else
Me.txtChange = (Me.Sales - mvarPriorSales) / mvarPriorSales
End If
mvarPriorSales = Me.Sales

This assumes a text box to display the change, with these properties:
Name: txtChange
Format: percent
ControlSource: {leave this blank}
 
Back
Top