Solved

change group field from VB

Posted on 2004-08-10
5
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 10

Expert Comment

by:ebolek
ID: 11762254
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
ID: 11762342
0
 
LVL 4

Author Comment

by:daleyjem
ID: 11765009
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
ID: 11799600
Closed, 125 points refunded.
CetusMOD
Community Support Moderator
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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