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

Variable number of variable groups

edited August 2002 in General
The spec says this: the report interface will contain a list of 7
possible report-groups. The user can select between 1 and 7 of these.
The user can also move the order of the groups around.

Some of the columns in the report are averages, so group totals must
each be independently calculated (ie, not simply report variables).

The detail row columns are a single defined set of columns.

I will need to create the groups at runtime.

The columns in the group band footers will always be the same, but I
guess if I am creating the groups at runtime I will have to put these in
at runtime as well, all in the correct positions.

The columns in the group footers will have to either call the same
procedure and the name or level of the group band will have to be
available to the code, or else each group can call a different procedure
to perform the calculations for the group row.

The calculations for the groups will be a nightmare but I will handle that.

1 Is there any chance of completing a report like this in a few days or
is this a much bigger project?

2 Any suggestions for how to do all this?

3 Any productivity tips for this? For example, I guess I'll drop text
labels onto the report where the group columns will go and read the x,y
positions off them, note them down, and then delete the text labels.

Thanks in advance.

Comments

  • edited August 2002
    This is going to be a dynamically created report. There is a report
    tutorial in the installed Developer's Guide on creating a report in code.
    Once you can create a report in code and it is working, then you'll need to
    begin controlling the dataset based on the group selection the user wants.

    The report will create groups based on the values coming in the dataset. The
    report will not reorder the dataset to fit the group definition. You'll
    have to provide the user a way to select an order for the dataset in a
    custom dialog before you print the report, or you can let them move the
    order by fields in the query dataviews in the Data tab. Now that the data is
    ordered, you can dynamically create the groups and calculations. There is a
    tech-tip newsgroup article in the code based thread called "Creating a Group
    in Code." You can dynamically create TppVariables and assign their OnCalc
    event handlers also.

    Are you going to use RAP? There is an example RAP demo which shows how to
    create a RAP event handler in code. We also have some custom demos we've
    coded and can email them to you as well, if you need further assistance.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited August 2002
    I will (of course) handle the selection, grouping, and ordering of the
    data. I have the dialog for that part written.

    I was hoping I could create the report with a heading and a detail line
    using the designer. Then I would dynamically add the groups (1 to 7
    groups), with a group header and group footer for each, plus the same
    text labels in the columns for each group (but different names for the
    text labels obviously), plus an event for each group. In the event, I
    need to calculate the group totals and set them as values for the group
    footer's text label fields. Because there are averages and also
    non-distinct rows in the report, these cannot be done using system
    variables (calcs etc.).

    The different groups event will have to call the same procedure, so the
    procedure needs a way of knowing which group called it. If this is very
    difficult, then I guess I could make 7 procedures for events (ie
    TMyForm.EndGroup1, TMyForm.EndGroup2, etc.) and just keep track of how
    they were assigned when I created the groups.

    I don't know how to give the text label fields in the dynamic groups the
    correct positions, sizes, fonts, alignments, etc. I figured I could
    create a group in the designer, create these labels in the right places,
    read off their properties manually, delete them, and then use the
    handwriten property information when I dynamically create them.

    One problem however is the top property - is this relative to the band
    (I hope) or the form (I hope not) ?

  • edited August 2002
    Hope to get your thoughts on my reply above...
  • edited August 2002
    You can create groups dynamically. Then track which ones you created and
    hook the objects up to the correct event handler, based on the order they
    were created for the report. The top property is relative to its band.
    I'll send you a dynamic report creation example which creates groups and
    other controls in the report. Send an email to
    support@digital-metaphors.com and I'll reply with an example attached.


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.