Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Display Group name value using RDC

Status
Not open for further replies.

Dan777

Programmer
Jul 22, 2000
34
0
0
US
Does anyone know how to display the Group Name Value in the Group Header using the RDC for a newly added group? I have no problem adding the group, setting its condition field and all, but when it comes to actually displaying the value of the group, I'm at a loss. For example, if a newly added group is based on the field Customer, how do ya get the actual Customer name (i.e. "Crystal Decisions, Inc.") to display in the group header? I use the AddGroup method of the application object to add the group, but I'm not finding anywhere to indicate that the group name value should be displayed. Thanks much for any help with this issue.
Dan
 
Dan777, do you mind sharing the code on how to add the group? I need to create a report during the run time.

thanks
 
Chris, there's probably other ways to do this, but the way I found that I was able to get working is to use the AddGroup method of the report object. Such as:

LOCAL loCR as CrystalRuntime.Application
LOCAL loReport as CrystalRuntime.Report

loCR = CREATEOBJECT("CrystalRuntime.Application")
loreport = loCR.NewReport()

loreport.AddGroup(0,loreport.Database.Tables(1).Fields(1), LOC_crGCAnyValue, LOC_crAscendingOrder)

Note this is Visual Foxpro code (not everyone codes in VB <s>).

The 4 parameters passed to the AddGroup method are the group number in the report (this is the 1st group), the condition to group on (in this case its that field, and you can't use the field name like 'customer.cname' there, you have to use reference the position in the database heirarchy), the Group Condition (which can be all kinds of weird stuff, in this case, that LOC_crGCAnyValue simply says to start a new group whenever that field changes), and then the sort order.

The thing about this AggGroup method is that it will not display the group name on the report, i.e. the &quot;customer's name&quot; will not be placed in the group header automatically, which is what happens when you add a new group to a report in the regular Crystal IDE. What's really frustrating is that in the CrystalDevHelp.chm they have a sample for adding a new group to a report, but they state right at the top of the sample code &quot;Please note that using this method will not display the group name on the report&quot;. And of course they don't state what to use to display the name. So if you can figure out how to display the name, please let me know.

Thanks,
Dan
 
Dan777, after you add the group can you add &quot;addformulafield&quot; to your groupheader with text = &quot;{customer.name}&quot;? where you able to add formulas to your group footer?
 
chris, I searched but didn't even find an &quot;addformulafield&quot; method. What I had been trying to use is AddFieldObject, such as AddFieldObject(&quot;{customer.cname}&quot;,100,0). The thing was that it kept giving me the invalid param error. What really sucked is that an example I found on crystaldecisions web site for adding groups used that exact syntax. I just figured out that specifying the field name as table.field doesn't work there, it has to be a reference to the field in the database object heirarchy, such as loreport.database.tables(1).field(3). So sometimes to add a field to a report the syntax AddFieldObject(&quot;{customer.cname}&quot;,100,0) does work, but not everytime, sometimes it has the heirarchy reference.
 
so, ok you add the group but how you add values to display in that group? In my case I have empty report at the beginning. I add groups and totals depend on user selection. My totals have to be formulas.
 
The first question is what section do you want to add those values to, i.e. details, group footer, etc. Then you can just use whatever to add values to it. In my report I have values displayed in the details that I've added using things like: loreport.sections(&quot;D&quot;).AddFieldObject(&quot;{customer.cname}&quot;),100,0)
and then added sum totals to the group footer using things like: loreport.sections(&quot;GF1&quot;).AddSummaryFieldObject(&quot;{customer.nSales}&quot;),LOC_crSTSum, 100,0), where the LOC_crSTSum is a constant performing a SUM.

As far as implementing actual formuals into the report, I really haven't got that far yet, as the current report I'm working on doesn't use any. I think it's something to do with the FormulaFieldDefinitions collection.
 
I will try it today with AddFieldObject tonight (it's my second work from home).

thanks
 
Dan777, I was able to create my reports. Looks very nice, used your tip, thanks. As to my group names I just did &quot;AddFieldObject&quot; = the fieldName I grouped by.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top