[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

Hide columns in Crystal Reports 9 report from code in VB6

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
bmutch
Asked:
bmutch
  • 5
  • 5
  • 2
1 Solution
 
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
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
 
bmutchAuthor Commented:
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
 
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
You can use the Report Creation api, but that requires that your users (each company) own at least one Crystal Developer license.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mlmccCommented:
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
 
bmutchAuthor Commented:
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
 
bmutchAuthor Commented:
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
 
mlmccCommented:
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
 
bmutchAuthor Commented:
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
 
mlmccCommented:
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
 
bmutchAuthor Commented:
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
 
mlmccCommented:
If you suppress them they won't show so position and size shouldn't matter

mlmcc
0
 
mlmccCommented:
Glad i could help

mlmcc
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now