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
Solved

Hide columns in Crystal Reports 9 report from code in VB6

Posted on 2007-04-07
12
474 Views
Last Modified: 2013-12-25
I am using crystal reports 9 in Visual Basic 6. I need to hide some columns in the report, based on user selections, how can I do this?

thank you.
bmutch
0
Comment
Question by:bmutch
  • 5
  • 5
  • 2
12 Comments
 
LVL 22

Expert Comment

by:Ido Millet
ID: 18870881
Create multiple sections (e.g., Detail a and Detail b) with didderent column layout in each.  Enter an expression into the suppress attribute of each section that, depending on a parameter value, shows only one of the sections and suppresses the rest.
0
 

Author Comment

by:bmutch
ID: 18870985
My table has about 30 columns, to get all the possible column combinations I would have to have 2^30 or 1073741824 details sections!, please tell me there is some other method.
0
 
LVL 22

Expert Comment

by:Ido Millet
ID: 18871200
You can use the Report Creation api, but that requires that your users (each company) own at least one Crystal Developer license.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 100

Expert Comment

by:mlmcc
ID: 18871296
Is there a set ofcolumns most users want all the time?

Perhaps you candevelop a small set of reports that will satisfy the users.

mlmcc
0
 

Author Comment

by:bmutch
ID: 18871452
Can't I do something like this:


    Set sec = Report.Sections(1)  ' the detail section

    For Each oObject In sec.ReportObjects
       if oObject.Name is "HideThisField" then
        oObject.supress
       end if
    Next oObject
0
 

Author Comment

by:bmutch
ID: 18871479
the following does seem to prevent the field data from being printed to the report, but do you know of any way to now shift the fields I don't want printed to the end of the report, or change the width of the fields to zero:

 Set sec = Report.Sections(1)
 Set oFieldObject = sec.ReportObjects(1)
 oFieldObject.Suppress = True
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 125 total points
ID: 18872397
Shifting fields requires the use of the CRAXDDRT library which requires a license for each user.

Perhaps the easiest way to do this would be to use formulas for all the fields on the report and change them from the application.  The problem with this approach is you will have trouble with field widths.
http://support.businessobjects.com/communityCS/FilesAndUpdates/SCR8_VB_RDC_DynamicFormulas.exe.asp

http://support.businessobjects.com/communityCS/FilesAndUpdates/SCR8_VB_RDC_CheckFormula.exe.asp

here is an example using the report creation API but I believe it requires either Crystal loaded or the runtime license
http://support.businessobjects.com/communityCS/FilesAndUpdates/scr8_vb_rcapi_grouponformula.exe.asp

mlmcc
0
 

Author Comment

by:bmutch
ID: 18875713
Are you sure that shifting fields requires the license for the target computer? The following code worked to switch the labels in the header section and the text boxes in the detail section, after installing my program on a test computer without the license:

    Dim sec As CRAXDRT.Section
    Dim oFieldObject As CRAXDRT.FieldObject
    Dim objtext As CRAXDRT.TextObject

    ' swap label fields
    Set sec = Report.Sections(2)
    Set objtext = sec.ReportObjects(15)
    objtext.BackColor = vbYellow
    objtext.Left = 7920
   
    Set sec = Report.Sections(2)
    Set objtext = sec.ReportObjects(13)
    objtext.BackColor = vbRed
    objtext.Left = 6240
   
    ' swap detail fields
    Set sec = Report.Sections(7)
    Set oFieldObject = sec.ReportObjects(2)
    oFieldObject.BackColor = vbYellow
    oFieldObject.Left = 7920
   
    Set sec = Report.Sections(7)
    Set oFieldObject = sec.ReportObjects(3)
    oFieldObject.BackColor = vbRed
    oFieldObject.Left = 6240
   
    CRViewer91.ViewReport
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18875916
If it didn't warn you then it may be ok.  I was under the impression that it required a license but that may be if you allow the user to do it rather than through code.

Your program will be very complex since the user can select many variations.  

A personal opinion.
The resulting reports may not look as polished since fieldplacement and width will be limited to what you hard code.  If the result is fine with your users then great.

mlmcc
0
 

Author Comment

by:bmutch
ID: 18898142
I plan on suppressing all the values that the user doesn't want to see, setting the width of these columns to the minimun (it wont let me set them to 0, only 60), and moving them to the far right side, so hopefully the end result will look ok.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18898899
If you suppress them they won't show so position and size shouldn't matter

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 19065811
Glad i could help

mlmcc
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

791 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