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

Artificial Grouping Variable

edited June 2004 in RAP
Dear all.

First I am not sure if this is the correct forum to post this. I am working
on converting some Crystal Reports files to RB 7.02. I am new to RB, but I
have worked extensibly with CR and did some Delphi work in the past,
although it feels like ages ago. If there is a more appropiate forum to list
these basic questions, please let me know.

The file that I am working on right now is an inventory value report based
on a database that has field named stocknum. I need to group by category
descriptions that are not in the database. The category description is based
on the first 2 characters of stocknum. In the Crystal Reports file I created
a variable named CodeDescription wich was setup as follows:

if Left ({consinv.STOCKNUM},2) = "BA" then "01320 Bathroom"
else
if Left ({consinv.STOCKNUM},2) = "BO" then "01340 Boiler"
else
if Left ({consinv.STOCKNUM},2) = "CA" then "01330 Carpenty"
else
if Left ({consinv.STOCKNUM},2) = "CD" then "Deleted"
else
if Left ({consinv.STOCKNUM},2) = "EL" then "01380 Electrical"
else
if Left ({consinv.STOCKNUM},2) = "KI" then "01310 Kitchen"

And so on and so forth. I then need to use the CodeDescription variable to
group the report.

I also need to split the report depending on whether the inventory belongs
to PHA or VET(erans). I had setup a variable in CR named
CodeDescriptionFiler as follows:

if Left ({consinv.STOCKNUM},2) = "BA" then "PHA"
else
if Left ({consinv.STOCKNUM},2) = "BO" then "PHA"
else
if Left ({consinv.STOCKNUM},2) = "PL" or Left ({consinv.STOCKNUM},3) = "PLU"
then "PHA"
else
if Left ({consinv.STOCKNUM},3) = "VCA" then "VET"
else
if Left ({consinv.STOCKNUM},3) = "VEL" then "VET"

I need to popup a prompt so that the user can select which inventory items
to report, PHA or VET. This I know how to do because I have already created
reports that prompt for date ranges, but I am wondering how I would access
the above variable once it is setup.

Can the above be accomplished with RB 7?

Your response will be greatly appreciated.

Mike.

Comments

  • edited June 2004

    1. The RAP newsgroup is appropriate for questions related to implementing
    report code that resides in the Report Designer's Calc Workspace. (This is
    contrast to writing report event-handlers using Delphi code). A brief
    explaination of the focus of each newsgroup can be found at

    http://www.digital-metaphors.com/Subpages/Support/Newsgroups.html

    2. The Group feature requires that the data be sorted on the group field.
    You need to use a SQL query to sort the data. With your current database
    tables, you are limited to ordering the SQL query by the StockNum field or
    you could use the SQL substring function to select the first 2 characters.

    Example:

    Select SubString(StockNum from 1 for 2) CategoryID
    from consinv
    order by 1

    3. You can Group on a TppVariable. Use the Variable OnGetText event to
    assign the value to the Text parameter that is passed to the event.

    if myPipeline['CategoryID'] = 'BA' then
    Text := '01320 Bathroom'
    else if ....

    4. You may want to consider adding a table to the database that would
    contain the Category Descriptions. That would be much simpler and more
    maintable going forward.



    --

    Thanks for supporting ReportBuilder! Please vote for ReportBuilder in the
    Delphi Informant Readers Choice awards!

    http://www.delphizine.com/ballot2004/


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.