Solved

Hide columns in Crystal Reports 9 report from code in VB6

Posted on 2007-04-07
12
473 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 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