Checking for last detail record to change formatting

  • Thread starter Thread starter Max Moor
  • Start date Start date
M

Max Moor

Hi All,
I'm trying to do an org chart, of sorts. A subreport, linking to the
main report with master and child fields, is used to show the "second
level" management below the top level people. The subreport draws
connector lines, like in an MS explorer file tree display.

The problem is that the last record in the second level (sub-report)
draws the same connector lines, even though there is no next-second-level-
person following. I have this dangling, attaches-to-nothing line left
over.

Is there a way, in VB code, maybe in the detail format event code of
the subreport, to detect that the subreport is displaying the last record
of the master's set? That way, I can set the lines .Visible property off,
and have the lines terminating with the last record, as expected.

- Max
 
Max said:
I'm trying to do an org chart, of sorts. A subreport, linking to the
main report with master and child fields, is used to show the "second
level" management below the top level people. The subreport draws
connector lines, like in an MS explorer file tree display.

The problem is that the last record in the second level (sub-report)
draws the same connector lines, even though there is no next-second-level-
person following. I have this dangling, attaches-to-nothing line left
over.

Is there a way, in VB code, maybe in the detail format event code of
the subreport, to detect that the subreport is displaying the last record
of the master's set? That way, I can set the lines .Visible property off,
and have the lines terminating with the last record, as expected.


You can determine the last record in a report by adding a
text box (name it txtTotalLines) to the report's header
section with the expression =Count(*)

To determine which record you're working on, add a text box
(name this one txtLineNum) to the detail section. Set tis
control source expression to =1 and RunningSum property to
Over All.

With all that in place the subreport's detail format event
can use something like this air code:

If Parent.txtLineNum = Parent.txtTotalLines Then
' last detail in main report
Else
' all other details
End If
 
You can determine the last record in a report by adding a
text box (name it txtTotalLines) to the report's header
section with the expression =Count(*)

To determine which record you're working on, add a text box
(name this one txtLineNum) to the detail section. Set tis
control source expression to =1 and RunningSum property to
Over All.

With all that in place the subreport's detail format event
can use something like this air code:

If Parent.txtLineNum = Parent.txtTotalLines Then
' last detail in main report
Else
' all other details
End If


Very cool! Thanks Marsh.
 
Back
Top