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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add group based on formula via RDC?

Status
Not open for further replies.

Elanger

Programmer
Jan 9, 2002
17
US
Crystal 8.5, VB 6
I'm trying to add a group to a report in VB using the RDC.

This works perfectly ...
myReport.AddGroup 0, myReport.Database.Tables(1).Fields(10), crGCAnyValue, crAscendingOrder
myReport.Sections.Item("GF").NewPageAfter = True
myReport.Sections.Item("GF").ResetPageNumberAfter = True

However, what I really want to do is base the group on a formula (in this case, the first character of the field in question--not the entire field). I cannot find any syntax that allows you to add a group based on a formula, as opposed to a field. Is this possible?

Or is my best approach to build the report *with* the group, and then remove the group when it's not necessary, as opposed to adding it when it is necessary?

Any help would be appreciated.
Thanks!
Elky Langer
 
I believe that adding and deleting groups from the app moves your application into the 'royalties required' area. It is unclear from the documentation since they list 'deleteGroup' as a royalty function, but 'addGroup' is not listed in either place that I could find.

You can pre-add the groups in the report and then nullify them from the code by:

1) Changing the group field to a formula that results in a constant (like {Datefield}- {Datefield} ) .
2) Suppressing both the Group Headers and Group Footers.

If you do these 2 things, the group is still there but is invisible. And these things can be clearly done without royalties. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Okay, so the second approach is the way to go. Thanks for the tip.

As an aside, I had absolutely no idea that manipulating the report via RDC may require royalties. I didn't look into it extensively, but my original impression was that allowing the user to manipulate reports required royalties ... but not the programmer. Is this documented anywhere? I do not want to spend time creating reports and using the RDC to work with them, and then discover that I require royalties!

At the very least, the program should warn you if you're using "royalty required" functionality vs. the standard ones ...

Thanks for the help.
Elky Langer
 
OK, I take it back. :) After researching a bit, I discovered that you do get warned if you use one of the royalty-required functions. (Still seems like a strange approach to me, though.)

So I guess I can safely assume that if AddGroup went through without a warning, it is not a part of the royalty-required group. Still, I will try the second approach and see how it goes.

Elky Langer
 
The license.hlp file goes into detail on which files and which functions require royalties. However it doesn't mention AddGroup in the list that I can find. It does mention that anything from CraxDDrt (not CraxDrt) is a royalty function but I haven't researched to find where AddGroup comes from.

If the warning doesn't match the license, I am pretty sure the license would win. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Your approach worked very well, thanks. I ended up suppressing just the group header, and not the group footer. I moved the total there, instead of using the report footer--that way I got subtotals for the group when needed, and a grand total when I reset the group to a constant.

One last question: In the preview screen in VB, the left-hand pane shows the group. This is nice when there's a legitimate group there, but in this case--when I'm "faking" the group--it just looks strange, and potentially confusing for the user. Is there a way to avoid showing this?

I often use suppressed groups to order a report, and I would rather not have the user see what's going on behind the scenes--it's too confusing. A "turn off group pane" feature would be very helpful!

Elky Langer
 
I don't think you can shut it off, but you can control what it says within the formula. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I'll look into it. Thanks very much for all your help!

Elky Langer
 
You can turn off the group tree using the properties of the viewer control. Judith

Judith Ullman
Director of Training and Consulting
Innovative Information Resources
Phone/fax: 212-904-0707

Innovative is the Metro New York Crystal Decisions Partner,
specializing in training and consulting in Crystal Reports and report distribution products, along with Oracle training and Data Junct
 
Judith is correct, if you don't want it at all you can shut it off for all groups using this property. I don't think you can shut it off conditionally for just the 'dummy' groups. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Actually, I don't really understand the initial request - if you want to group on a formula, you should be able to do it with code like this:

myReport.AddGroup 0, myReport.FormulaFields(1), crGCAnyValue, crAscendingOrder

The formula field must exist before using it here. Judith

Judith Ullman
Director of Training and Consulting
Innovative Information Resources
Phone/fax: 212-904-0707

Innovative is the Metro New York Crystal Decisions Partner,
specializing in training and consulting in Crystal Reports and report distribution products, along with Oracle training and Data Junct
 
Judith,

>> myReport.AddGroup 0, myReport.FormulaFields(1), crGCAnyValue, crAscendingOrder<<

Thanks, that's what I was looking for. This isn't documented in the help file--it only mentions database fields.

I'll also shut off the group tree, since I think it looks confusing. Do you know if there's a way to shut off the little mouse tips that pop up in the main viewer window, when the mouse passes over each field?

Thanks!
Elky Langer
 
Keep in mind that the RDC talks about &quot;field objects&quot;. These refer to database fields, formula fields, and parameter fields, that is, any Crystal object that can be treated like a field.

Re tool tips, I don't remember off-hand, but since you're working in VB, click on the viewer control and you can see all the properties in the VB properties window. That is a complete list.

You can set the tool tips yourself in the report designer - it's in the Format/Common window. Maybe you can set them to &quot;&quot;, and nothing will come up, but more likely an empty tip will come up.

Judith Ullman
Metro New York Crystal Decisions Training and Consulting Partner
 
judith,

While we are on the subject, can you confirm if the addgroup property does or does not require royalties. The DeleteGroup does (according to the license.hlp file), but the AddGroup isn't listed anywhere that I could find. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks very much for all your help. I've changed several of the properties of the viewer control in VB and it does look much better.

Setting to &quot;&quot; does bring up an empty tip, as you thought, so I'll just have to live with it for now!

Elky Langer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top