Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

How to find the detail count?

edited February 2002 in General
I am trying to show a sub-report that has title and detail bands. I have a
variable that I increase in the detail band, so that it show a numbered
list.

If there is only one record in the detail band, then I want to hide the
variable, since a numbered list with only one item looks a bit odd. I've
tried all sorts of things, but can't seem to get it to work.

I tried a DBcalc in the title section, set to lookahead and count the items
in the detail section which it does show correctly in the title, but it
seems not to look ahead until afterward, since when I try to decide whether
to show my number variable, the value of the DBcalc seems to increment as it
goes through the report.

How can I achieve what I want?

Regards
Jeremy Knowles

Comments

  • edited February 2002
    Here is a demo. No subreport, but you can take the same approach such that
    the group is located inside of the subreport. You can resize the group
    header and group footer to be zero height, and base the group on a custom
    field such as a label to get a group around the entire subreport.
    Essentially, you'll need to get a event to yank the draw command when the
    subreport is finished. This may be possible by using a summary band of zero
    height in the subreport. It won't print, but its BeforePrint event handler
    should fire and do that same job as the group footerband. Now that I think
    about it, the summary in a subreport is the way to go on this event handler,
    forget creating a group since you don't need it.

    http://www.digital-metaphors.com/tips/HideVarWhenOneRec.zip


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited February 2002
    Thanks Jim, that works great... almost.

    There is one thing though. I put the stuff in the summary band AfterPrint
    event, and it works fine except when there is some at the bottom of the
    previous page and only one detail that goes onto the next page, in which
    case Detail.Count = 1 so the variable is hidden when it should be shown.

    I got round it by making the sub-report keep together which forces them all
    onto the next page, but it would be nicer to fix it.

    Thanks again, this product and support is fantastic, but then I guess you
    know that - one more comment doesn't harm though, eh?

    Jeremy

  • edited February 2002
    Ok, then take the demo's group approach, such that there is one group inside
    the subreport which never breaks. Create the group on a custom field, such
    as a static text TppLabel.


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.