Number each detail record in a report

  • Thread starter Thread starter Ed Dobbin
  • Start date Start date
E

Ed Dobbin

Hi There:
I was wondering if it is possible to reset the generated
numbers based on a text box higher up in the hierarchy of
the report.
I know that set ControlSource property =1
set RunningSum property to Overall gives me the detail
numbers I need, but I would like to reset the number back
to 1 again as my text box for region number changes. Can
this be done?
Ed
 
Hi Nikos:
I tried that already but then my numbers reset too often.
They reset after each building number. I really need them
to reset after each region number changes.
My report is structured as follows.
Volume #
Region #
District #
Dept.#
Property Name
Location

I want to number each property line and then reset the
number only when the region # changes.
Ed
 
Ed,

I haven't tried this before, but I suspect you'd have to use some code to do
it. One way is something along the lines of:

Public Reg
Public Prop

Function Prop_Num(Reg_ID)
If Reg <> Reg_ID then
Prop = 1
Reg = Reg_ID
Else
Prop = Prop +1
End If
Prop_Num = Prop

The controlsource of your counter control needs to be changed from =1 to
=Prop_Num([ControlName]), where ControlName is the name of the Region #
control, and its Running sum property reset to No.

You will also make sure you reset the public variables before you run the
report each time, just to be on the safe side, so I would suggest you use a
sub like:

Sub Run_Report()
Reg = Null
Prop = 0
DoCmd.OpenReport "ReportName", acViewPreview '(or acViewNormal to print)

HTH,
Nikos
 
Back
Top