Solved

change group field from VB

Posted on 2004-08-10
5
196 Views
Last Modified: 2012-05-05
how do i change the field that a group is grouped by in my report from Visual Basic?
0
Comment
Question by:daleyjem
5 Comments
 
LVL 10

Expert Comment

by:ebolek
Comment Utility
This is hpw you do it in .net. VB must be similat to it.

Logic is
Create a formula field in the report.
Then in the vb find that formula field from formulafield collection
insert a group to the report by using the formula created
chnage the text propertty of the formula to the field that you want to group by in VB

Regards
Emre

private void ChangeGroupName(CrystalDecisions.CrystalReports.Engine.ReportDocument MyReport, string strGroupName)
            {
                  //change the group name for fieldday reports
                  
                  foreach(CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition crField in MyReport.DataDefinition.FormulaFields)
                  {
                        //start changing the header of the chart according to the group name passed
                        if (crField.Name  == "GroupField")
                        {
                              switch(strGroupName)
                              {
                                    case "client":
                                          crField.Text = "{uspReport_DaysWorked_View." + strGroupName + "}";
                                          break;
                                    case "rep_name":
                                          crField.Text = "{uspReport_DaysWorked_View." + strGroupName + "}";
                                          break;
                                    case "work_comp_state":
                                          crField.Text = "{uspReport_DaysWorked_View." + strGroupName + "}";
                                          break;
                                    default:
                                          crField.Text = "{uspReport_DaysWorked_View." + strGroupName + "}";
                                          break;
                              }                  
                        
                        }      
                        //start chart title formula field
                        if (crField.Name  == "ChartTitle")
                        {
                              switch(strGroupName)
                              {
                                    case "client":
                                          crField.Text = "\"Field Days Assigned By Client\"";
                                          break;
                                    case "rep_name":
                                          crField.Text = "\"Field Days Assigned By Sales Representative\"";
                                          break;
                                    case "work_comp_state":
                                          crField.Text = "\"Field Days Assigned By State\"";
                                          break;
                                    default:
                                          crField.Text = "\"Field Days Assigned By Ops Code\"";
                                          break;
                              }
                        
                        
                        }
                        
                        
                  }
                  
                  
                  
            
                 
            }
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
0
 
LVL 4

Author Comment

by:daleyjem
Comment Utility
sorry mlmcc, but that link takes me to a forum where the link is a downloadable .exe

i figured out what i need to do...

before... i was using a crystal report control out of the VB6 toolbox.
this time, i actually referenced the Crystal Report 7 Engine Object, and also kept the crystal report control on my form with it's file name pointing to the right spot.

then i added this code:

    Dim crpApplication As New CRPEAuto.Application
    Dim crpReport As CRPEAuto.Report
    Dim crpDatabaseField As CRPEAuto.DatabaseFieldDefinition
    Set crpReport = crpApplication.OpenReport("c:\filename.rpt")

    If Option1.value = True Then
        Set crpDatabaseField = crpReport.Database.Tables.Item(1).Fields.Item(2)
    Else
        Set crpDatabaseField = crpReport.Database.Tables.Item(1).Fields.Item(1)
    End If

    'This is the group area of the report
    crpReport.Areas.Item(3).GroupOptions.ConditionField = crpDatabaseField
    'Display the report

    If Option1.value = True Then
        crpReport.FormulaFields(1).Text = "{Permissions.Procedure}"
    Else
        crpReport.FormulaFields(1).Text = "{Permissions.User}"
    End If

    crpReport.Preview

<--- End of Code --->

ebolek, i'm not real familiar with the syntax of your code...
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
Comment Utility
Closed, 125 points refunded.
CetusMOD
Community Support Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now