Solved

Hide columns in Crystal Reports 9 report from code in VB6

Posted on 2007-04-07
12
471 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

743 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