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

How to add a group with the RDC that is a formula? 1

Status
Not open for further replies.

bodwellr

Programmer
Apr 17, 2001
2
US
How do you add a group to a report with the RDC that is a formula?
 
The following code sample illustrates how:

Dim crAppl as New CRAXDRT.Application
Dim crRpt as CRAXDRT.Report

Set crRpt = crApp.OpenReport(App.Path & "/" & cSalesOrders)

Dim crField As CRAXDRT.FormulaFieldDefinition

Set crField = crRpt.FormulaFields.GetItemByName("Year")

crRpt.AddGroup 0, crField, crGCAnyValue, crAscendingOrder

The first argument, "0", is a zero-based index representing the position in the group structure the new group should take. It is somewhat counter-intuitive in that group 1 doesn't correspond to GH1 in the Crystal report. Rather, 0 would be Group 1, 1 would be Group 2, etc.

Also, while the group tree in the viewer will show the group and it's values, the RDC doesn't automatically place anything in the group header or footer. And adding items in there may require using CRAXDDRT and paying royalty fees.
 
I guess I was hasty in approving the response I received.

It does not work in version 8 or 8.5 does not like the crField being assigned in the AddGroup.
 
I wrote the code using CR 9, but tested it with the CR 8.5 RDC and it works the same. So, please post the error message you are getting, and the exact code you've written to implement the above sample. Obviously, the formula name "Year" needs to be replaced by your formula, and--one thing I didn't mention--the formula must already exist in the Crystal report (even if the formula text will later be changed).
 
Hi bodwellr

Have you managed to resolve the above issue?

I am too having trouble with rpt1FielD assignment as well.

ie: rpt1.AddGroup (1,rpt1FielD,14,crAscendingOrder)


Set app1 = CreateObject("crystal.CRPE.Application")
Set rpt1 = app1.OpenReport(strapppath & "\Sales.rpt")


Set rpt1DatabasE = rpt1.Database

Set rpt1TableS = rpt1DatabasE.Tables
Set rpt1TablE = rpt1TableS("Customer")

Set rpt1FieldS = rpt1TablE.Fields


Set rpt1FielD = rpt1FieldS("Region")

Set rpt1AreA = rpt1.Areas(3)
Set rpt1GrouP = rpt1AreA.GroupOptions


rpt1.AddGroup (1,rpt1FielD,14,crAscendingOrder)

However I fall bad at
this point --->> Set rpt1FielD = rpt1FieldS("Region")


Any help woudl be appreciated.



 
sultan123:

From your code, it appears that you're using CPEAUT32.DLL. You don't show how you've declared the variables, nor do you show the error message you get on the line that fails, so it makes it hard to determine what your issue is. The code below works with the CR 8 CPEAUT32.DLL and should get you in the ballpark:

--------------------------------------------
Dim crwApplication As CRPEAuto.Application
Dim CRWReport As CRPEAuto.Report

Private Sub Form_Load()

Dim crwDB As CRPEAuto.Database
Dim crwTable As CRPEAuto.DatabaseTable

Set crwApplication = CreateObject("Crystal.CRPE.Application")
Set CRWReport = crwApplication.OpenReport("C:\Program Files\Microsoft Visual Studio\VB98\Archived Apps\Report Integration Cert\Customer Profile.rpt")

Set crwDB = CRWReport.Database

Dim crTable As CRPEAuto.DatabaseTable
Dim crField As CRPEAuto.DatabaseFieldDefinition

Set crTable = crwDB.Tables("Employee")
Set crField = crTable.Fields("Employee ID")

CRWReport.AddGroup 1, crField, crGCAnyValue, crAscendingOrder

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top