P. 1
20 Secrets of Crystal Reports

20 Secrets of Crystal Reports

|Views: 378|Likes:
Published by 1sanyi

More info:

Published by: 1sanyi on Jun 29, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

06/29/2011

pdf

text

original

Sections

  • Critical Skill Deficit
  • Cost of Inadequate Preparation
  • Training Resources Available
  • #1 How to display every nth record in Crystal Reports
  • # 2 How to display only the report file name on the report
  • #3 How to suppress a blank subreport from displaying on the main report
  • #4 How to Share Subreport Data with the Main Report
  • #5 How to evaluate null field values in formulas or record selection criteria
  • #6 How Different 'Keep Together' Options Affect the Report
  • #8 Suppress a section that contains a blank subreport
  • #9 How to create a table of contents for a report
  • #10 How to add time fields
  • #11 What font types are supported in Crystal Reports
  • #12 How to format specific words or characters within a string
  • #13 How to Display a Date Range Parameter on a Report
  • #14 How to suppress a blank subreport
  • Crystal Reports for Visual Studio .NET
  • Summary
  • Summary:
  • Worldwide contact information

Crystal Reports® Secrets

20 Secret Shortcuts and Workarounds for Crystal Reports Designers and Developers

This guide is for your personal use, compliments of Business Objects Education Services. It contains a concise summary of answers to the most common Crystal Reports questions, along with links to more detailed explanations. Created to help report designers and developers quickly improve their skills, this guide was: • • • Developed by the people who wrote the code – experts who can explain their secrets, step by step Based on the most common questions identified by Technical Support Designed to help you get the most out of Crystal Reports. Learn to unlock the value inside your information to help your organization improve business performance.

..

ii

Business Objects • Crystal Reports Secrets

Contents

Why these secrets are so important i.) Critical skill deficit ..................................................................................... 5 ii) Cost of inadequate preparation ........................................................... 6

iii) Impact on IT project success .................................................................. 7 iv) Training resources available ................................................................... 8

Top 20 Secrets Secrets for Report Designers: #1. How to display every nth record in Crystal Reports ........................ 9 #2. How to display only the report file name on a report ...................11 #3. How to suppress a blank subreport from displaying....................12 #4. How to share subreport data with the main report .......................15 #5. Evaluate null field values in formulas or record selection ..........18 #6. How different 'Keep Together' options affect the report .............23 #7. How to export to PDF or RTF in Crystal Reports............................28 #8. Suppress a section that contains a blank subreport ....................30 #9. How to create a table of contents for a report ...............................39 #10. How to add time fields .........................................................................43 #11. What font types are supported in Crystal Reports? ....................47 #12. How to format specific words or characters within a string ......50 #13. How to display a date range parameter on a report ....................52 #14. How to suppress a blank subreport .................................................54

iii

Business Objects • Crystal Reports Secrets

.... What is Unicows....................56 #16......................................... How to create a report and add a parameter field using Report Creation API ....................................79 iv Business Objects • Crystal Reports Secrets ...76 Summary: ................NET...........................NET ......................60 #18... How to deploy an application that uses Crystal Reports and VS ...NET application ........................................................ How to change the data source using CR for VS ...............NET................70 #20..............................dll and where can you find it? ...........Contents Secrets for Developers: #15..... Crystal Reports for Visual Studio ......................................................................... How to pass Database logon info to a Crystal Report at runtime in VB .....65 #19.......................59 #17................................78 • More resources available Worldwide contact information: ...................

enterprise resource planning (ERP) and customer relationship management (CRM) solutions – yet frequently fail to arm their people with the training they need to get the most out of the implementation. According to Meta Group research. three out of every four ERP users raise the white flag – they do not have the skills they require.Critical Skill Deficit Fact: Many users are not adequately prepared Organizations around the world invest in business intelligence (BI). Overlooked: Let’s learn a lesson from ERP Three out of four ERP users lack competency 76% user competency substandard or failing 83% didn’t institute a comprehensive training plan 24% user competency satisfactory 42% no end-user training beyond that provided at the end of the implementation Source: Meta Group research. August 2003 as cited in ZD Net online article “Three out of four ERP users raise the white flag. The good news is that the time you invest in learning the secrets presented in this document and in formal learning will pay off right away – in greater efficiency. and better reports. boosted confidence.” 5 Business Objects • Crystal Reports Secrets .

Cost of Inadequate Preparation Fact: Preparation and skill development are key project success factors The impact of inadequate preparation may be greater than you think.3% Source: Chaos Report N= 365 IT Managers http://www1.5% Lack of IT Management 6.3% Changing Requirements & Specifications 8.php 6 Business Objects • Crystal Reports Secrets .7% Lack of Planning 8.com//sample_research/chaos_1994_2.9% Lack of Executive Support 9.1% Didn’t Need it any longer 7. We all suffer from the tyranny of the urgent – putting off learning critical skills even though we will desperately need these very skills in the middle of a demanding project.standishgroup.6% Unrealistic Expectations 9.1% Lack of User Involvement 12.4% Lack of Resources 10. Here is the question: What is the cost of failure or delay on your project? Why do IT Projects fail? • • • • • • • • • • Incomplete Requirements 13.2% Technology Illiteracy 4.

forecasting and other related value-based analysis” Hackett Best Practices Strategic Decision Making benchmark. “On average. an unguided learning process is much less effective than a systematic approach to training. business opportunities. Learning the techniques that make a user proficient requires a one-time investment – whereas failure to master these techniques requires a time investment every time the user performs a task. 2002 “68% of IT executives said training of users would improve information access” Business Week Survey 7 Business Objects • Crystal Reports Secrets . At those companies where BI tools and technologies have been implemented in a consistent manner. roughly 20 percent of an individual's time is spent gathering and collecting. while 80 percent is spent reporting and analyzing the information for trends. most individuals spend 50 percent of their time gathering and collecting the information for standard report analysis and the remaining time analyzing the information.Impact on IT project success Fact: The real cost of skill deficit is high Organizations often believe that users are resourceful enough to find their own way through new programs and systems. While this may be true.

Trained users take advantage of 20% more product features – and have both greater competence and higher confidence as a result of their training.Training Resources Available Fact: Continuous learning yields exponential benefit Once you’ve had a chance to digest these tips and tricks.com/training) Building and Creating Business Views 1 Source: Analysis of post class evaluations.businessobjects. • 95% of trainees rank their experience as “good” to “excellent” in terms of job 1 relevance. Learn from the experts. • Only the creators of the software have in-depth understanding of all of the software features.com/training) Designing and Deploying a Solution • Crystal Enterprise: (http://www.businessobjects. • Business Objects Education group has trained over 200.com/training) Administering Servers • Crystal Enterprise: (http://www.businessobjects. 8 Business Objects • Crystal Reports Secrets .com/training) Business Reporting Solutions Courses for Crystal Enterprise Administrators: • Crystal Enterprise: (http://www.businessobjects. • We employ only the most experienced instructors – professionals with a proven track record in sharing time-saving tips and best practices. Both classroom and elearning training is available. you’ll probably want to take your skills to the next level. Courses for Crystal Reports Designers: • Report Design I: ( http://www. the people who created the software. 2004.com/training) Administering Users and Content • Crystal Enterprise: (http://www.com/training ) Fundamentals of Report Design • Report Design II: (http://www.businessobjects.000 users.businessobjects.

2.#1 How to display every nth record in Crystal Reports #1 How to display every nth record in Crystal Reports http://support. Solution: A formula can be created that will display every nth record by conditionally suppressing all other records. The formula editor opens.com/library/kbase/articles/c2014881.asp The information in the article refers to: Crystal Reports 10 Applies to: Reported version and lower Formulas Conditional Suppression Format Section Synopsis: In Crystal Reports (CR). 3. Example Formula: Remainder((recordnumber). click the details section. is it possible to display every nth record without indexing the database table? For example. Your report connects to a database table that does not contain an indexed field. On the 'Sections' list.businessobjects. Right-click on the details section and click 'Section Expert'. To apply this formula in the Section Expert: 1. The example below shows how to display every 25th record. you have a report with 100 records but you only want to see every 25th record. 9 Business Objects • Crystal Reports Secrets .25) <> 0 You will employ this formula in the Section Expert. Leave the check box cleared and click the 'X+2' command button next to 'Suppress (No Drill-Down)'.

Refer to 'Courses & Schedules' at: http://www. refer to the Crystal Reports Online Help by pressing the 'F1' key. More Information For more information about the 'Remainder' function or 'Record Number' special field.#1 How to display every nth record in Crystal Reports 4. 6.crystaldecisions. 5. CR reads the results of the formula to determine if a record will appear.com/training 10 Business Objects • Crystal Reports Secrets . Click OK in the Section Expert. All other records do not display on the report because of the conditional suppression at the details level. Background Information This formula returns a value of true for all records not divisible by 25 and a value of false for all records that are divisible by 25. Training: Learn more about Crystal Reports . Type the formula provided by this article.Report Design. Save your formula and close the formula editor. You will now only see every 25th record.

# 2 How to display only the report file name on the report # 2 How to display only the report file name on the report http://support. NumberVar i := Ubound(File).5.'\'). because it uses the special field 'filename'. 9. or it will return an empty string. File[i].com/training 11 Business Objects • Crystal Reports Secrets . use a formula similar to this: @ReportFileName: //This is the formula name StringVar Array File:=Split(filename.crystaldecisions.com/library/kbase/articles/c2015683. Solution To display just the report file name on a report. How do you display just the report file name on the report? NOTE: The report must be saved before the formula will return a value.asp The information in the article refers to: Crystal Reports 10 Applies to: All versions Formulas Return File Name Synopsis When using the special field called 'filename' the report shows the entire path including the file name.businessobjects. which exists in Crystal Reports 8. Training: Learn more about Crystal Reports . and 10.Report Design. Refer to 'Courses & Schedules' at: http://www. This formula is not version-specific and can be placed in any report.

5 and earlier. You want to suppress the sections of the blank subreport. How can you suppress a blank subreport from displaying on the main report. For more information on how to suppress blank subreports in CR 9. Since the subreport is inserted into the main report. This means the Crystal Reports designer does not consider a section that contains a subreport as a blank section. if there is no data. If the subreport does not contain any data.com/library/kbase/articles/c2000055.asp The information in the article refers to: Seagate Info.#3 Suppressing a blank subreport from displaying on the main report #3 How to suppress a blank subreport from displaying on the main report http://support. Seagate Crystal Reports 5 Applies to: Reported version and lower Hiding subreports that have no records Using 'Suppress Printing if No Records' checkbox Synopsis NOTE: New to Crystal Reports 9 is the 'Suppress Blank Subreport' check box. you want to suppress the sections within a subreport. it cannot be entirely suppressed. Even when a subreport does not have any records. To workaround this. Moreover. Solution NOTE: This workaround applies to Crystal Reports 8. A subreport is an object within the Crystal Reports designer. 12 Business Objects • Crystal Reports Secrets . you must first suppress the blank subreport. so that it does not display on the main report? For example: There is a subreport contained in the main report. then shrink the blank section.businessobjects. from the 'Section Expert' does not work. refer to our knowledge base article c2011893. You notice that by selecting the 'Suppress if blank' option. the subreport object still exists within a section of the main report. you do not want it to display in the main report.

On the 'Format' menu of the main report. resize the height of the subreport object so it is as short as possible. This means you still cannot format the main report section that contains the blank 1. Format the subreport object so there are no borders: · on the main report. right-click the subreport object and click 'Format Subreport'. the subreport still exists as an object in the main report. Move the subreport object so it is at the very top of the section. complete the following: 1. and then click 'OK' to return to the report. · on the 'Borders' tab. 13 Business Objects • Crystal Reports Secrets . This takes you to the 'Subreport' tab of the main report. Return to the 'Preview' tab of the main report. 3. Bottom. Right and Left boxes. 4. Select the section containing the subreport. select the 'Fit Section' checkbox. and then click 'OK'. Blank subreports now appear as empty boxes on the report. In the main report. In 'Design' tab of the main report. Select the 'Suppress Printing if No Records' checkbox. select 'None' from the Top. 2.#3 Suppressing a blank subreport from displaying on the main report Suppressing a Blank Subreport NOTE: To suppress the blank subreport. 5. 4. · Click 'OK' to return to the report. 3. 5. click 'Section'. right-click the subreport object and click 'Edit Subreport'. complete the following: This only suppresses the subreport from printing. Shrinking a Blank Section To shrink the blank section. so you will not see the contents of the subreport. click 'Report Options'. Refresh the report. 2. On the 'File' menu.

Training: Learn more about Crystal Reports . that the solution in knowledge base article c2005853 requires inserting another subreport.Report Design. CAUTION: If you want to actually suppress the section in the main report that contains the blank subreport.#3 Suppressing a blank subreport from displaying on the main report Now when you preview the main report. Keep in mind. Refer to 'Courses & Schedules' at: http://www.com/training 14 Business Objects • Crystal Reports Secrets . instead of merely concealing the blank subreport on the main report. which will significantly increase the time it takes to process and display your report. refer to knowledge base article c2005853. the blank subreports are hidden from view.crystaldecisions. however.

For example if you want to pass a grand total from the subreport to do a calculation in the main report. the other to retrieve the value from the shared variable. make it easier to pass values from a subreport to the main report. In the subreport. follow these steps: 1.businessobjects. create a formula similar to the one below: //@SubFormula //Stores the grand total of the //{Orders.asp The information in the article refers to: Seagate Info. Data from the subreport is required for calculations in the main report. 15 Business Objects • Crystal Reports Secrets . Crystal Reports 7 Applies to: Reported version and higher Shared variables Passing data between subreport and main report Synopsis A report contains a subreport.#4 How to Share Subreport Data with the Main Report #4 How to Share Subreport Data with the Main Report http://support.com/library/kbase/articles/c2007600.Order Amount} field //in a currency variable called 'myTotal' NOTE: This is not possible with On Demand Subreports in Crystal Reports. How can you share subreport data with the main report in version 7 (or higher) of the Crystal Reports Designer? Solution Shared variables. The most important thing to remember when using shared variables is that Crystal Reports must first evaluate the formula where the value is stored before evaluating the formula that retrieves the shared variable. introduced in Crystal Reports version 7. Using shared variables requires two formulas: one to store the value in a shared variable.

In the main report. Place this formula in your subreport.Order Amount} field. 3. click the section containing the subreport. · Click 'Insert' (at top of dialog box). create a formula that declares the same variable name: //@MainFormula //Returns the value that was stored //in the shared currency variable called //myTotal in the subreport WhilePrintingRecords. In this particular example. and place @MainFormula in this new sub-section: · On the 'Format' menu. Shared CurrencyVar myTotal := Sum ({Orders. click 'Section'. 16 Business Objects • Crystal Reports Secrets . · Click 'OK' to return to the report. myTotal 4. you must place @MainFormula in a main report section that is beneath the section containing the subreport. that value was the grand total of the {Orders. · On the 'Sections' list. and insert @MainFormula into this new subsection.#4 How to Share Subreport Data with the Main Report WhilePrintingRecords. @MainFormula displays the value from the subreport. This inserts an additional subsection. For the shared variable to return the correct value in the main report. One way to do this is to insert a section below the section containing the subreport.Order Amount}) 2. Shared CurrencyVar myTotal. Place @MainFormula in a main report section that is beneath the section containing the subreport. This ensures Crystal Reports evaluates the @SubFormula before @MainFormula. The next time you preview the report.

such as: //@NewFormula //includes data from subreport {@MainFormula}+ Sum ({Customer. You have now successfully shared data from a subreport with the main report.#4 How to Share Subreport Data with the Main Report 5.com/training 17 Business Objects • Crystal Reports Secrets . you can include this formula in other main report formulas.Report Design III training course. Refer to 'Courses & Schedules' at: http://www.businessobjects. or in a section further down on the report. Training Learn more about subreports in the Crystal Reports .Last Year's Sales}) Place this formula in the same section as @MainFormula. Once you have verified that @MainFormula is returning the correct value from the subreport.

How can you evaluate this database field in formulas or record selection criteria to return the expected result set? Example Scenario 1.asp The information in the article refers to: Crystal Reports 9 Applies to: All versions Record selection criteria Formula displays unexpected results IsNull function Synopsis A database field contains values and null values. to the Details section of the report. {YourDatabaseTable.com/library/kbase/articles/c2010914. a list of values and blank values appears in the Details section.businessobjects. Add a Number field.NumberField}. In Crystal Reports (CR). 18 Business Objects • Crystal Reports Secrets . Field values contained in the database 1 <Null> <Null> 2 3 Field values that appear in CR 1 <blank space> <blank space> 2 3 NOTE: The <blank space> in CR represents the null values from the database field. when previewing the report.#5 How to evaluate null field values in formulas or record selection criteria #5 How to evaluate null field values in formulas or record selection criteria http://support.

the values that appear on the report are not what you expected. * The null values in a String (Text) field are converted to an empty string ("") value. EXAMPLE DEFAULT VALUES BY DATA TYPE * The null values in a Number field are converted to a zero (0) number value. Expected field values based on record selection criteria 1 <blank space> <blank space> 2 Field values that appear in CR based on the record selection criteria 1 2 Why do the null values not appear in the result set based on the record selection criteria? How can you evaluate the null values in the Number field to return the expected result set? Why do blank values or incorrect values appear in the result set of a formula? Solution The expected result set does not appear because the example of record selection criteria does not evaluate the null values. Add the following record selection criteria to the report: {YourDatabaseTable. In CR.NumberField} < 3 3. use one of the following solutions: Option A) Convert the null value to the default value of their data type. Upon adding the record selection criteria. Null values in the Number field are not evaluated as zero (0) values by default. 19 Business Objects • Crystal Reports Secrets .#5 How to evaluate null field values in formulas or record selection criteria 2. to evaluate fields that contain null values to return the expected result set.

0. 20 Business Objects • Crystal Reports Secrets . If applicable. Click File > Report Options 2.OR Option B) Evaluate the null value within record selection criteria or within formulas using the IsNull function. * The null values in a Date-time field are converted to zero (0. A) STEPS TO CONVERT NULL FIELD VALUES TO DEFAULT VALUE FOR ALL FIELDS IN CR 1. specify a value or action if the IsNull function evaluates a null record. 0) date-time values. Click 'OK'.#5 How to evaluate null field values in formulas or record selection criteria * The null values in a Date field are converted to zero (0. 0. CR is now able to successfully evaluate any null or blank values contained in the database fields according to the default value of their data type. 3. 0. B) STEPS TO EVALUATE THE NULL FIELD VALUES IN CR 1. Use the IsNull function at the beginning of the formula or record selection criteria. NOTE: The IsNull function evaluates the database field(s) for null values. Follow the steps below for A) or B) to correctly evaluate the null values to return the expected result set. blank values or incorrect values appear because the formula includes a database field that contains null values. . Follow the steps below for A) or B) to evaluate null values to return the expected result set. 0. 2. Select the 'Convert NULL Field Values to Default' check box. It is important to evaluate every database field included in the formula or record selection criteria for null values. 0) date values. Create formula or record selection criteria. 3. with regards to the related issue. Selecting 'Convert NULL Field Values to Default' affects all database fields on the report. 0. Also.

the total is //increased by the value of the record. For example. WhilePrintingRecords.Datefield} < CurrentDate. Numbervar Total. If IsNull({YourDatabaseTable. Stringvar Message. If the record contains a //null value. the following behavior occurs in CR when a null value is encountered: * Formulas or record selection criteria stop evaluating the null value. the total is increased by a zero value. //Also. Background information If the 'Convert Null Field Values to Default' check box is not selected or if the database field has not been evaluated using the IsNull function.StringField}) = "" Then Message := "Your Message" Else Message := {YourDatabaseTable. c) Evaluate for null values in a String or Text field //This formula evaluates if the String field contains null records.StringField}) or Trim({YourDatabaseTable. CR will successfully evaluate null field values in a formula or record selection criteria to return the expected result set. the Trim //formula function is used to account for a blank space caused by pressing the Space Bar. if the 21 Business Objects • Crystal Reports Secrets .NumberField}) Then Total := Total Else Total := Total + {YourDatabaseTable. date values are returned where it is less than the current date.DateField}) And {YourDatabaseTable.StringField} Upon completing the above steps. Additionally. If IsNull({YourDatabaseTable.NumberField}. Not IsNull({YourDatabaseTable. b) Evaluate for null values in a Number field to create a total //This formula evaluates if the Number field contains null records.#5 How to evaluate null field values in formulas or record selection criteria EXAMPLES OF THE ISNULL FUNCTION IN A FORMULA OR RECORD SELECTION CRITERIA Evaluate for null values in a Date field //Date values that are not null are returned based on this record selection criteria. If the record is not null. Whileprintingrecords.

Training: Learn more about additional functions in the Crystal Reports .#5 How to evaluate null field values in formulas or record selection criteria formula is incrementing a value based on the database field. the value does not increment nor does the remainder of the formula continue to evaluate.crystaldecisions. the formula continues on to evaluate the next record. Refer to 'Courses & Schedules' at: http://www. it is possible to return incorrect values. However. * Formulas or record selection criteria return a blank value.Report Design II training course. If the formula's calculations are based on the field values.com/education 22 Business Objects • Crystal Reports Secrets .

5 Applies to: Reported version and lower Keep Group Together Keep Columns Together Keep Object Together Synopsis In the Crystal Reports (CR) Designer.businessobjects.#6 How Different 'Keep Together' Options Affect the Report #6 How Different 'Keep Together' Options Affect the Report http://support. The 'Keep Together' options affect how the report displays the particular object or section.asp The information in the article refers to: Seagate Info. Crystal Reports 8. how do the different 'Keep Together' options affect the report? The 'Keep Together' options in CR are as follows: * Keep Together * Keep Group Together * Keep Object Together * Keep Columns Together Where do you find the 'Keep Together' options in CR and how do they affect your report? Solution The 'Keep Together' options are available to format objects and sections of the report. this article provides the following: * Where to find the 'Keep Together' options * Example report details * How the report is affected based on the example report details Report sections and commonly used report objects that include the 'Keep Together' 23 Business Objects • Crystal Reports Secrets . Based on the report sections and commonly used report objects.com/library/kbase/articles/c2010715.

the entire Group Footer section will begin at the top of the next page. NOTE: 'Keep Together' is unavailable for the Page Header and Page Footer sections. 3. select 'Keep Together' check box. EXAMPLE REPORT DETAILS: * The Group Footer is three inches in height. Details B) Group Options C) Subreports. This is by design. Under the Common tab. Group Header/Group Footer. Text Objects. Each Page Header and Page Footer is already designed to keep together at the top and bottom of each page. When the 'Keep Together' option is selected. And Other Database Fields D) Cross-tabs A) REPORT HEADER/REPORT FOOTER. Business Objects • Crystal Reports Secrets . Click Format > Section. Use the 'Keep Group Together' option as described in B) 24 2. DETAILS To locate the 'Keep Together' option for the different sections of the report. GROUP HEADER/GROUP FOOTER. NOTE: Do not use this option if your intention is to keep the entire group together. In the Section Expert. CR keeps the entire instance of the particular section on the same page. * There is only one inch available at the end of the page. Based on the EXAMPLE REPORT DETAILS. follow these steps: 1.#6 How Different 'Keep Together' Options Affect the Report options: A) Report Header/Report Footer. select the section. Ole Objects. * The 'Keep Together' option is selected for the Group Footer section.

Right-click the report object. Details and Group Footer are displayed for each group instance. follow these steps: 1. Click 'OK'. Do not use this option if the intended purpose is to have each group start on a new page. the entire group instance will start on a new page. * The amount of space required to display for a group instance exceeds the remaining space available on the report page. Click the following options depending on whether you are inserting a new group or changing an existing group: * Insert > Group for inserting a new group * Report > Change Group Expert > Options for changing an existing group 2. C) SUBREPORTS. The entire group instance includes the Group Header. follow these steps: NOTE: If the group instance spans multiple pages. 'Keep Group Together' option starts on a new page and continues through the multiple pages until the particular group instance is completed. If more than one group instance can fit on one page. TEXT OBJECTS. AND OTHER DATABASE FIELDS To locate the 'Keep Object Together' option for formatting subreports. 3. Based on the EXAMPLE REPORT DETAILS. Under the "Group Options" heading. 2. OLE objects. more than one group instance will display on the same page. OLE OBJECTS. Details and Group Footer. EXAMPLE REPORT DETAILS: * The Group Header. select the 'Keep Group Together' check box. text objects. If the intended purpose is to have each group start on 1.#6 How Different 'Keep Together' Options Affect the Report B) GROUP OPTIONS To locate the 'Keep Group Together' option for inserting or changing a group. Select the one of following available options depending on the object type: * 'Format Subreport' for subreports * 'Format Text' for text objects * 'Format Graphic' for OLE objects * 'Format Field' for database fields 25 Business Objects • Crystal Reports Secrets . and other database fields.

Based on the EXAMPLE REPORT DETAILS. select the 'Keep Columns Together' check box. · The Group is not formatted with the 'Keep Group Together' option. 3. EXAMPLE REPORT DETAILS: · The Report Footer contains a cross-tab. When the 'Keep Object Together' option is selected. the Group Footer instance and the text object will start on the previous page. · The text object is placed above the subreport. · The subreport in the Group Footer instance exceeds the remaining ·mount of space available on that page. Under the Common tab. However.#6 How Different 'Keep Together' Options Affect the Report 3. Under the Customize Style tab. The 'Keep Object Together' option is only applicable to the particular object. D) CROSS-TABS: To locate the 'Keep Columns Together' option for formatting a cross-tab. · The text object is not formatted with the 'Keep Object Together' option. Based on the EXAMPLE REPORT DETAILS. · The cross-tab columns span multiple pages. the subreport will start on a new page. Select 'Format Cross-tab'. · The Group Footer contains a subreport and a text object. select the 'Keep Object Together' check box. Right-click the cross-tab. · The subreport is formatted with the 'Keep Object Together' option. · The Group Footer section is not formatted with the 'Keep Together' option. follow these steps: 1. the 'Keep Columns Together' option is 26 Business Objects • Crystal Reports Secrets . EXAMPLE REPORT DETAILS: · The Group Footer contains a subreport and a text object. CR keeps the columns together if a column width spans across to a second page. When the 'Keep Columns Together' option is selected. CR keeps the entire instance of the particular object on the same page. 2.

Training Learn more about object and section formatting options in these courses: · Crystal Reports .com/training 27 Business Objects • Crystal Reports Secrets .Report Design II Refer to 'Courses & Schedules' at: http://www.Report Design I · Crystal Reports . the columns that would span across the edge of the pages start on a new page. A cross-tab column is not divided between two pages.businessobjects.#6 How Different 'Keep Together' Options Affect the Report selected.

asp The information in the article refers to: Crystal Reports 9 Applies to: Reported version and lower Report Design Exporting to PDF and RTF Synopsis Can I export my report to Adobe Acrobat PDF (Portable Document Format) or RTF (Rich Text Format) from the Crystal Reports report designer? If so.5 and later allows exporting to PDF.#7 Exporting to PDF or RTF in Crystal Reports #7 Exporting to PDF or RTF in Crystal Reports http://support.com/library/kbase/articles/c2006248. 2.5 retains the best WYSIWYG (What-yousee-is-what-you-get) format of the original report. Click the destination of your choice from the 'Destination' drop-down box.5 support many features that other exporting formats cannot. Exporting to PDF and RTF in Crystal Reports 8. click 'Acrobat Format (PDF)' from the 'Format' drop-down box. Exporting to PDF in Crystal Reports 8 and earlier is not supported. click 'Export'.) 4. click 'Disk file'. Exporting to PDF or RTF in Crystal Reports 8. On the 'File' menu. Click 'OK'. Export to PDF NOTE: This export DLL is designed to work with Adobe Acrobat 1. how? Solution Crystal Reports 8. 28 Business Objects • Crystal Reports Secrets . (To save to a file on your computer. Crystal Reports 8 and later allows exporting to RTF. 3. In the 'Export' dialog box.businessobjects.

com/search Training Learn more about exporting in the Crystal Reports .businessobjects. 8.zip · For Crystal Reports version 8.SCR8_ExportLimitations. Refer to 'Courses & Schedules' at http://www. 3.) 4.com/training 29 Business Objects • Crystal Reports Secrets .5 .5. Click 'OK'. For information on ALL the formats that Crystal Reports has exporting functionality to. and 8. 2. These information sources are available on our website: http://support.businessobjects. In the 'Export' dialog box. click 'Disk file'. download the applicable document. click 'Export'.SCR7ExportLimitations. On the 'File' menu.cr85_exportlimitations. (To save to a file on your computer. · For Crystal Reports version 7 .cr9_exportlimitations. Click the destination of your choice from the 'Destination' drop-down box. click 'Rich Text Format' from the 'Format' drop-down box.zip · For Crystal Reports version 9 . More Information For information on troubleshooting errors exporting to PDF and RTF refer to our knowledge base article c2012282.zip · For Crystal Reports version 8 .Report Design I training course.pdf These documents also list all supported and unsupported exporting features in Crystal Reports 7.#7 Exporting to PDF or RTF in Crystal Reports Export to RTF 1.

You notice that by selecting the 'Suppress if blank' option. how do you suppress a section in the main report that contains a blank subreport? For example: A subreport is placed in the group header of the main report.5. Seagate Crystal Reports 8. 30 The group header that contains the blank subreport does not shrink because the subreport is an object within the Crystal Reports designer. Solution NOTE: New to Crystal Reports 9 is the 'Suppress Blank Subreport' check box.com/library/kbase/articles/c2005853. For more information on how to suppress blank subreports in CR 9. You want to suppress the group header of the main report when the subreport is blank. from the 'Section Expert' does not work.5 Applies to: Reported version and lower Seagate Info Blank Subreports Conditional Suppression Synopsis In Crystal Reports (CR) 8. 8 and 8. 7. The following procedures must be completed in order to achieve the desired results: · creating a duplicate subreport · placement of a duplicate subreport Business Objects • Crystal Reports Secrets .businessobjects.#8 Suppress a section that contains a blank subreport #8 Suppress a section that contains a blank subreport http://support. You notice that if the subreport does not return data the group header contains a blank space the size of the subreport.asp The information in the article refers to: Seagate Info. refer to our knowledge base article c2011893. This knowledge base article provides a solution to suppress a section that contains a blank subreport for CR 6.5 and earlier. A section containing a subreport is never blank even if the subreport is because it contains a subreport object.

create another group header and place the duplicate subreport into it. From the fly-out menu. by inserting another group header you notice that there is group header A and group header B. complete the following: Creating a Duplicate Subreport Place the duplicate subreport into the section above the original subreport. From the main report in CR. if the subreport is located in the group header.5 To suppress a section that contains a blank subreport in CR 7. From the fly-out menu. Select 'Choose a report'.#8 Suppress a section that contains a blank subreport · creating a formula to test if the subreport is blank · conditionally suppressing a section that contains original subreport · minimizing a duplicate subreport and resizing the section NOTE: You must create another subreport based on the original subreport. 3. 7. For example. if the original subreport is contained in the group header of the main report. from the 'Insert' menu. For example. You notice another section is inserted into the report labeled 'b'. select 'Save Subreport As'.5. To create a duplicate subreport. right-click the left gray margin at the group header level. Insert the duplicate subreport by selecting 'Subreport'. 5. For example. complete the following steps: 1. Browse to find the duplicate subreport. In design mode. 2. 4. 2. complete the following steps: 1. from the 'Insert Subreport' dialog box. 6. 3. 8 and 8. drag and drop it into the second section. To insert a section into the report. Placement of a Duplicate Subreport Crystal Reports 7. 8 and 8. Select the report and click 'Open'. 31 Business Objects • Crystal Reports Secrets . Select the original subreport. right-click the left gray margin where the subreport is located. rightclick the subreport. select 'Insert Section Below'. Provide a name for the duplicate subreport and click 'Save'.

10. Place @CheckForNull in the Report Header of the duplicate subreport. on the 'Edit' menu click 'Subreport Links'. The top drop-down box will contain both the original and duplicate subreports. 5. Creating A Formula To Test If The Subreport Is Blank In the duplicate subreport. select 'Edit Subreport'.field})) or Count(Table. If IsNull(Count({Table. Also.field) = 0 then Suppress:= TRUE Else Suppress:= FALSE 6. you must create a formula to test whether the contents of the subreport are blank. complete the following steps: 1. In the main report. CheckForNull. For example. 32 Business Objects • Crystal Reports Secrets . To create this formula. From the 'Insert' menu. select ' select 'Field Object'. The duplicate subreport will be attached to the cursor. 2. Create a formula similar to the following: // @CheckForNull Whileprintingrecords. Click 'OK'. Compare these two subreports and enure that the fields in the 'Filed(s) to link to' box are the same. check that the parameter in the bottom-left drop-down box and the field in the bottom-right dropdown box are the same. Select 'Formula Fields' and select the 'New' icon. This launches the formula editor. Insert the subreport in the new section (such as group header b from step 2). Type a name into the 'Formula Name' box and click 'OK'. This launches the 'Field Explorer'. Right-click on the duplicate subreport and from the fly-out menu.#8 Suppress a section that contains a blank subreport 8. 4. The results of this formula are going to be stored as a shared variable and shared with the main report. 3. Shared BooleanVar Suppress. 9.

From the fly-out menu. and from the fly-out menu. select the section that contains the original subreport. However. 3. right-click the duplicate subreport. the section that contains the duplicate subreport is visible on the main report. create a formula similar to the following: // The section will be suppressed if // variable Suppress is True Whileprintingrecords. Minimizing the Duplicate Subreport & Resizing the Section To minimizing the duplicate subreport on the main report and resize the section. select 'Edit subreport'. 6. select 'Section'. 2. 2. Select the main report. Right-click the duplicate subreport. Ensure the checkbox is clear. From the 'Format' menu. complete the following steps: 1. you notice that the sections that contain a blank subreport are suppressed. Shared BooleanVar Suppress = True Now when you preview the report. 5. 33 Business Objects • Crystal Reports Secrets . From the 'Format Editor'. Suppress all of the sections in the duplicate report. This launches the 'Section Expert'. 4. From the main report. select 'Format Subreport'. complete the following steps: 1. 3. Click the 'X+2' button beside the 'Suppress (No drill down) check box. 4. In order to suppress the section still visible you must minimize and resize the section. From the 'Section Expert' dialog box. In the 'Format Formula Editor'.#8 Suppress a section that contains a blank subreport Conditionally Suppressing a Section Containing Original Subreport To conditionally suppress the section that contains the original subreport. select the 'Border' tab.

To create a duplicate subreport. you will need to download uflstore. if the original subreport is contained in the group header the main report. Right. create another group header and place the duplicate subreport into it. Provide a name for the duplicate subreport and click 'Save'. To insert a section into the report. From the fly-out menu. Placement of a Duplicate Subreport Place the duplicate subreport into the section above the original subreport. Bottom. 2. Select the main report. right-click the subreport.com/downloads The reason you need to obtain this file is because shared variables were introduced in Crystal Reports 7. In design mode. Business Objects • Crystal Reports Secrets 34 . Crystal Reports 6 Before you begin this process.zip from our website at: http://support. For example. complete the following steps: 1. In order to suppress a section that contains a blank subreport in Crystal Reports 6. complete the following: Creating a Duplicate Subreport You must create another subreport based on the original subreport. 8. complete the following steps: 1. 9.#8 Suppress a section that contains a blank subreport 7. select 'None' for Left. From 'Line style'.crystaldecisions. you will need to use the store and fetch function. select 'Save Subreport As'. right-click the left gray margin where the subreport is located. Top. From the main report in CR. Resize the section that contains the duplicate subreport to be as small as possible. To suppress a section that contains a blank subreport in Crystal Reports 6. 3.

Select the original subreport. Select the report and click 'Open'. Browse to find the duplicate subreport. f the subreport is located in the group header. Insert the duplicate subreport by selecting 'Subreport'. 8. From the 'Insert' menu. drag and drop it into the second section. You notice another section is inserted into the report labeled 'b'. Right-click on the duplicate subreport and from the fly-out menu. For example. select ' select 'Field Object'. 2. The results of this formula are going to be stored as a shared variable and shared with the main report. from the 'Insert Subreport' dialog box. from the 'Insert' menu. This launches the 'Field Explorer'. you must create a formula to test whether the contents of the subreport are blank. The duplicate subreport will be attached to the cursor. 4. Compare these two subreports and enure that the fields in the 'Filed(s) to link to' box are the same. on the 'Edit' menu click 'Subreport Links'. select 'Insert Section Below'. by inserting another group header you notice that there is group header A and group header B. 3. check that the parameter in the bottom-left drop-down box and the field in the bottom-right dropdown box are the same. The top drop-down box will contain both the original and duplicate subreports. Creating a Formula to Test if the Subreport is Blank In the duplicate subreport. 5. Also. Select 'Choose a report'. 2. select 'Edit Subreport'. 7. 9. In the main report.#8 Suppress a section that contains a blank subreport For example. 35 Business Objects • Crystal Reports Secrets . To create this formula. right-click the left gray margin at the group header level. From the fly-out menu. 6. complete the following steps: 1. 10. Click 'OK'. Insert the subreport in the new section (such as group header b from step 2).

From the 'Section Expert' dialog box.field)) or Count(Table. If IsNull(Count(Table. select the section that contains the original subreport. Conditionally Suppressing a Section Containing Original Subreport To conditionally suppress the section that contains the original subreport. Select 'Formula Fields' and select the 'New' icon. This launches the 'Section Expert'.#8 Suppress a section that contains a blank subreport 3. you notice that the sections that contain a blank subreport are suppressed. 4. 2. Ensure the checkbox is clear. the section that contains the duplicate subreport is visible on the main report. For example. 4. Click the 'X+2' button beside the 'Suppress (No drill down) check box. In the 'Format Formula Editor'. This launches the formula editor. FetchBooleanVar("Suppress") = True Now when you preview the report. Type a name into the 'Formula Name' box and click 'OK'. Place @CheckForNull in the Report Header of the duplicate subreport. Create a formula similar to the following: // @CheckForNull Whileprintingrecords. create a formula similar to the following: // Conditional suppression on section containing original subreport Whileprintingrecords. CheckForNull. complete the following steps: 1. select 'Section'. False) 6. 36 Business Objects • Crystal Reports Secrets .field) = 0 then StoreBooleanVar ("Suppress". 5. 3. In order to suppress the section still visible you must minimize and resize the section. True) else StoreBooleanVar("Suppress". However. From the 'Format' menu.

From the fly-out menu. TIP: To distinguish between the section containing the duplicate subreport and the section containing the original subreport. you can format one of the sections with a different background color. Right. select 'Edit subreport'. From the 'Format Editor'. Resize the section that contains the duplicate. 4. Select the main report. From 'Line style'. Bottom. Right click the section to select it and from the fly out menu select 'Format Section'. From the main report. select the 'Border' tab. To format a section with a background color. follow these steps: 1. Select the desired color from the list. 9. 6. 5. 2. 37 Business Objects • Crystal Reports Secrets . 3. Suppress all of the sections in the duplicate report. select 'None' for Left. 4. Right-click the duplicate subreport. 3. select 'Format Subreport'. Select the main report. Top. 7. In the 'Section Expert' select the section containing the duplicate subreport from the 'Sections' dialog box. 2. right-click the duplicate subreport.#8 Suppress a section that contains a blank subreport Minimizing the Duplicate Subreport & Resizing the Section To minimize the duplicate subreport on the main report and resize the section. complete the following steps: 1. and from the fly-out menu. 8. Click the 'Color' tab and select the 'Background Color' check box.

com/training 38 Business Objects • Crystal Reports Secrets .crystaldecisions. Refer to 'Courses & Schedules' at: http://www.#8 Suppress a section that contains a blank subreport Training: Learn more about subreports in the Crystal Reports .Report Design III training course.

businessobjects.com/library/kbase/articles/c2011950. showing group names next to the page numbers the groups start on. WARNING: Crystal Reports is not recommended as a tool to write to. Database clients or applications designed specifically to edit databases should be used instead. now that CR has full SQL functionality it is possible to write to. Using a command object it is possible to write to a database from CR.asp The information in the article refers to: Crystal Reports 9 Applies to: Reported version only Table of Contents Subreports Add Command Synopsis In Crystal Reports (CR) 9. update and delete from databases. Your DBA needs to grant specific rights to your database. Before attempting to implement the steps in this article. However. consult your Database Administrator (DBA). 39 Business Objects • Crystal Reports Secrets . Solution You can make a table of contents using a subreport with a command object.#9 How to create a table of contents for a report #9 How to create a table of contents for a report http://support. is it possible to create a table of contents at the beginning of a report? A table of contents would be in the Report Header. The following example will use a subreport to write group names and page numbers to a new table in your database. This article is provided as a tip. update or delete from a database.

Grouper and TableOfContents. Insert the 'Table of Contents' subreport in the Report Header section. On a grouped report (for this example the report is grouped on the ProductName field). 40 Business Objects • Crystal Reports Secrets . Sort this subreport by the TableOfContents.Page fields in the Details section. The TableOfContents table will be updated as the report changes. In the Main report. Connect this subreport to the new TableOfContents table and insert the TableOfContents. Click the 'Create' button to create a parameter. the database has changed and the changes may not be reversible. 6. DELETE or UPDATE statements at your own risk. and then click 'Insert Section Below'. click 'Subreport'. 3. click 'Subreport'. Right-click the gray area to the left of the Report Footer. WARNING: Use INSERT INTO. 5. There will now be 'Report Footer a' (RFa) and 'Report Footer b' (RFb).#9 How to create a table of contents for a report Create a Table of Contents 1. In the 'Database Expert' dialog box. delete. Create three fields in this table: · Grouper (String data type)(Ensure this field is at least as large as your longest group field value) · Page (Number data type) · DateTime (DateTime data type) 2. Name this subreport 'UpdateTOC'. Name the parameter 'LinkReceiver' and click 'String' from the 'Value Type' drop-down box. and update this table to any users of this report. Assign rights to write to. Create a new table in your database called TableOfContents. DELETE or UPDATE statement has run. 7. on the 'Insert' menu. Create another parameter named 'DateTime' with a 'DateTime' value type. then double-click 'Add Command'.Page field. Name this subreport 'Table Of Contents'. The 'Add Command to Report' dialog box will appear. in the 'Insert' menu. browse to your Table of Contents data source. 4. Once a command object containing an INSERT INTO.

0) & ". create a formula named 'DateTime' with the following syntax: CurrentDateTime NOTE: The output of this formula will look similar to this: INSERT INTO TableOfContents VALUES ('Bikes'. "yyyy-MM-dd HH:mm:ss") & "')" & chr(10). Click 'OK' to close the 'Format Editor' dialog box. and then click 'None' from the 'Left'.2. 12. 8. Create another formula named 'LinkMaker' with the following syntax and place it in the Group Header section of the main report: WhilePrintingRecords.'2003-04-04 12:32:01') INSERT INTO TableOfContents VALUES ('Locks'." & ToText(PageNumber. Consult the database manual or Database Administrator for the correct syntax for your data source. Right-click the 'UpdateTOC' subreport. 'Top' and 'Bottom' drop-down boxes. (This is to ensure that the formula used to link the subreport is processed before the subreport is processed."DateTime" <> {?DateTime}. 10.'" & ToText({@DateTime}. Click the 'Border' tab. Insert the 'UpdateTOC' subreport in the Report Footer B (RFb) section.Product Name}) & "'. 'Right'. SELECT * FROM "TableOfContents" This command object will add new GroupName and PageNumber data to the TableOfContents table and delete any existing data based on the ?DateTime parameter. Insert the Grouper and the Page fields in the subreport Details section. link 41 Business Objects • Crystal Reports Secrets . Business Objects Technical Support does not provide support for writing SQL queries.1. Insert this formula in the main report's Report Header section. If Not InRepeatedGroupHeader Then link := link & "INSERT INTO TableOfContents VALUES ('" & GroupName ({Product. as they are database specific. Suppress all of the subreport sections. In the main report. 9. and then click 'Format Subreport'. 14.) 11. StringVar link.'2003-04-04 12:32:01') 13. In the 'Add Command to Report' dialog box enter a SQL Query similar to the following: {?LinkReceiver} DELETE FROM "TableOfContents" WHERE "TableOfContents".#9 How to create a table of contents for a report NOTE: This SQL Query (and any other SQL syntax in this article) is written for a Microsoft SQL Server database.

the report must be refreshed a third time to update the 21.Report Design. refresh the report twice to update the TableOfContents table. click 'Subreport Links'.com/training 42 Business Objects • Crystal Reports Secrets . click 'Special Field'. NOTE: If changes are made to the report that affect the page numbering. Repeat step 15. connecting the '@LinkPasser' Formula field to the '?LinkReceiver' parameter. StringVar link. Create another formula named 'LinkPasser' with the following syntax and place it in the Report Footer A (RFa) Section of the main report: WhilePrintingRecords. Click the '@DateTime' Formula field from the 'Available Fields' box and move it to the 'Field(s) to link to' box. Refresh the report again and the Table of Contents will display the group and page number values based on your report.#9 How to create a table of contents for a report 15. In the 'Field Explorer' of the main report. Preview the report to write the Table of Contents data to the database. 18. 19. in the 'Edit' menu. Training: Learn more about Crystal Reports . 20. In the 'Subreport Links' dialog box click the 'UpdateTOC' subreport from the 'For subreport' drop-down box.crystaldecisions. click the '?DateTime' parameter. In the 'Subreport parameter field to use' drop-down box. If the number of pages used by the Table of Contents changes. Click 'OK' to close the 'Subreport Links' dialog box. Insert the 'PageNofM' field in the Page Footer. 17. Refer to 'Courses & Schedules' at: http://www. In the main report. link 16.

If your field is a datetime field. Calculate the total time in seconds 3.asp The information in the article refers to: Seagate Crystal Reports 8 Applies to: Reported version and higher summing time fields converting seconds to hours.businessobjects.#10 How to add time fields #10 How to add time fields http://support. Create a new formula and call it @ConvertTimeToSeconds 43 Business Objects • Crystal Reports Secrets . seconds Synopsis The report contains a time field that displays in hh:mm:ss format.com/library/kbase/articles/c2008378. How do you create a formula in Crystal Reports (CR) that adds more than one time field and displays the total in the same format: hh:mm:ss? For example: 1:45:01 + 1:45:01 should display 03:30:02 and not 2:90:02 Solution In order to get the sum of more than one time field and to display the total of the time field in the same format (hh:mm:ss) you must complete the following steps: 1. Convert the seconds back to hh:mm:ss format. minutes. complete the following steps: 1. Convert all the time fields to a common time unit such as seconds 2. Convert time fields to seconds Convert the time fields to seconds so that a common time unit is used to sum up all three different time units.

local numbervar minutes.#10 How to add time fields 2. Create a formula similar to the following to convert the string field to seconds: local numbervar hours. local numbervar seconds. Create a new formula and call it @ConvertTimeStringToSeconds 2. // Convert the hours to seconds by multiplying by // 3600 hours := hour({@time}) * 3600. // Parse out the hours portion of the string and // multiply by 3600 to convert to seconds hours := tonumber({timestringfield}[1 to 2])* 3600. // Convert the minutes to seconds by multiplying by // 60 minutes := minute({@time}) * 60. To convert the string field. To convert the datetime field to seconds. Calculate the total time in seconds 44 Business Objects • Crystal Reports Secrets . // Parse out the seconds seconds := tonumber({timestringfield}[7 to 8]). with the format of hh:mm:ss to seconds create a formula similar to the following: 1. // Add up all the seconds hours + minutes + seconds. //add up all the seconds hours + minutes + seconds. // Parse out the minutes portion of the string and // multiply by 60 to convert to seconds minutes := tonumber({timestringfield}[4 to 5]) * 60. local numbervar seconds. seconds := second({@time}). local numbervar minutes. create a formula similar to the following: local numbervar hours.

local numbervar Seconds. Use truncate to remove the decimal //portion. local numbervar Hours . Group) Convert the seconds back to hh:mm:ss format Create a formula that converts the @TotalSeconds results back to hh:mm:ss format. To convert the results from @TotalSeconds back to hh:mm:ss format. and seconds to hh:mm:ss totext(Hours. local numbervar Minutes. create a formula similar to the following: local numbervar RemainingSeconds. Hours := truncate({@TotalSeconds} / 3600). minutes.OR sum(@ConvertTimeStringToSeconds. // Subtract the Hours and Minutes and what is left over is seconds. // Format the hours. // Subtract the hours portion to get RemainingSeconds RemainingSeconds := {@TotalSeconds} . Seconds := {@Totalseconds} ."00") 45 Business Objects • Crystal Reports Secrets ."00") + ":" + totext(Minutes. Create a new formula and call it @ConvertTotalSeconds 2.(Hours * / 3600). Minutes := truncate(RemainingSeconds/60). Group) . Create a new formula and call it @TotalSeconds 2.(Hours * 3600) ."00") + ":" + totext(Seconds. create a formula similar to the following: sum(@ConvertTimeToSeconds.(Minutes * 60). 1. To sum up either formula. // Divide RemainingSeconds by 60 to get minutes. Use truncate to remove the decimal portion. //divide the @TotalSeconds by 3600 to calculate hours.#10 How to add time fields Create a summary formula that will sum the @ConvertTimeToSeconds or @ConvertTimeStringToSeconds 1.

com/training 46 Business Objects • Crystal Reports Secrets . Refer to 'Courses & Schedules' at: http://www.#10 How to add time fields Training: Learn more about Crystal Reports .crystaldecisions.Report Design.

com/library/kbase/articles/c2011820.#11 What font types are supported in Crystal Reports #11 What font types are supported in Crystal Reports http://support. this knowledge base article answers the following questions regarding embedded fonts: a) What font types can be displayed within Crystal Reports? b) What font types are supported when exporting to PDF? c) How do you verify the embedded security level of a font? Solution a) The following font types can be displayed within Crystal Reports: · True Type Fonts (TTF) · True Type Collection (TTC) · Printer Font Metrics (PFM) · Adobe Font Metrics (AFM) · Printer Font Binary (PFB) · Printer Font ASCII (PFA) NOTE: Font File Names (FONT) is a font type that is not supported by Crystal Reports 47 b) The following font types are supported when exporting to PDF: · True Type Fonts (TTF) · True Type Collection (TTC) When exporting a report that contains a font type other than TTF or TTC to PDF format. the font is not successfully exported or the following error message appears: Business Objects • Crystal Reports Secrets .asp The information in the article refers to: Crystal Reports 9 Applies to: Reported version and higher Supported exporting fonts TTF Exporting to PDF Synopsis For Crystal Reports (CR).businessobjects.

However. the font types that are exported must allow embedding.This allows fonts to be embedded." c) To verify the embedded security level of a font. review the font properties. If the security level contains "No-embedding" permissions. Since PDF format embeds fonts. then exporting to PDF will not be successful. If a page allows fonts to be changed. Embedding permissions are determined by the font vendor. download the "Font properties extension" from Microsoft's web site at: www. · Print and preview .This allows fonts to be embedded similar to the "Editable" permissions. then editable or installable fonts are required. Note that installable fonts are not installed in the visitors' fonts folder. 48 Business Objects • Crystal Reports Secrets . The permissions associated with the embedded security level of a font are as follows: · No-embedding . Examples of a page that allows fonts to be changed are an online Java-based word processor or an email editor.This does not allow fonts to be embedded. Contact the font vendor to request a possible upgrade to an embeddable font. · Editable . · Installable .com /typography Summary Not all fonts that can be displayed in Crystal Reports are supported when exporting to PDF. only within pages that remains static on the client computer. True Type Fonts (TTF) has embedding permissions that determine if they can be converted into an embedded font format.#11 What font types are supported in Crystal Reports "<Font name> cannot be found.This allows fonts to be embedded using a tool such as Microsoft Web Embedding Fonts Tools (WEFT) beyond the limitations of the "Print and preview" permissions.microsoft. NOTE: For the utility to allow you to view the embedded security level of a font.

com/training 49 Business Objects • Crystal Reports Secrets .#11 What font types are supported in Crystal Reports Background Information New to version 9. Also. on our support site at: http://support. support for exporting embedded fonts is new to Crystal Reports 9.com Search for "Font Format Types" or "Font File Formats" on the Adobe support site at: http://support.com Related Information Search for the file name.com/docs Search for the knowledge base articles. Crystal Reports supports Unicode. c2011114 and c2010555. More Information Search for "Embedding Fonts" or "About Font Embedding" on the Microsoft support site at: http://support.crystaldecisions.adobe. double-byte characters can be displayed in Crystal Reports.microsoft.crystaldecisions.crystaldecisions.pdf.com/kbase Training: Learn more about Crystal Reports . Therefore. Scrprinterdependency. on our support site at: http://support. Refer to 'Courses & Schedules' at: http://www.Report Design.

com/library/kbase/articles/c2015491.businessobjects. to bold all occurrences of the word "City' in the Customer Name field of the Xtreme sample database.Customer Name}. Replace({Customer.asp The information in the article refers to: Crystal Reports 8. Right-click the formula field and click the 'Paragraph' tab in the Format Editor.#12 How to format specific words or characters within a string #12 How to format specific words or characters within a string http://support. for example. 50 Business Objects • Crystal Reports Secrets . 3. use this formula: //@boldcity //This is the formula name NOTE: Word or character formatting is limited to the supported HTML tags. A list of supported HTML tags can be found in the on-line help files by pressing F1. bold or underline. In the 'Text interpretation' list. How can you format occurrences of a specific word or character within a string field? Solution To format occurrences of a specific word or character within a string field.5 Applies to: Reported version and higher Formatting fields Word or character formatting HTML Synopsis In Crystal Reports (CR) there is no option to format occurrences of a specific word or character. within a string field. Click 'OK' to close the Format Editor. use the 'Replace' function in a formula to replace the word or character. 2. For example. "<b>City</b>") Place this formula field on the report instead of the database field 'Customer Name' and then select HTML Text Interpretation for the paragraph format as follows: 1. "City". click 'HTML Text'.

Refer to 'Courses & Schedules' at: http://www.crystaldecisions.#12 How to format specific words or characters within a string Training: Learn more about fonts in Crystal Reports.com/training 51 Business Objects • Crystal Reports Secrets .

when entering a date that is not in the database. For example: The database contains date values from November 3rd (11/3/97) to November 30 (11/30/97). If you enter '11/1/97' as the start date. the @DateRange formula in the Report Header displays "11/3/97 .businessobjects. These dates are then used in the report's record selection formula. date2:=Maximum ({Datefield}). a formula similar to the example below is placed in the Report Header: //{@DateRange} WhilePrintingRecords. Crystal Reports 6 Applies to: Reported version and higher Parameter fields Date range selection formulas in version 5. this formula returns confusing results. To display the date range for this report. DateVar date2. date1:=Minimum ({Datefield}).11/30/97". 6. & 7 Displaying the date range in a report Synopsis A report uses parameter fields to prompt you for a start and end date. "my selection is: " + totext(date1) + " " + totext(date2) However. and '11/30/97' as the end date. How can you resolve this issue? 52 Business Objects • Crystal Reports Secrets .asp The information in the article refers to: Seagate Info. DateVar date1.#13 How to Display a Date Range Parameter on a Report #13 How to Display a Date Range Parameter on a Report http://support. This happens because there are no records for November 1st and 2nd.com/library/kbase/articles/c2000534.

5. Go back to the 'Insert fields' dialog box to insert the End Date parameter into the text object.com/training Knowledge Base article C2002512 53 Business Objects • Crystal Reports Secrets . 2. which prompts for the start AND end dates. after the string 'to'. then type the string "to" (without the quotes). Refer to 'Courses & Schedules' at: To display the date range using Range Parameters. use text objects.crystaldecisions. you only need one date parameter. click 'Parameter fields'. Click the Start Date parameter and insert it into the text object. Using Text Objects to Display Date Range: 1. Place the text object in the Report Header. This opens the 'Parameter fields' tab of the 'Insert fields' dialog box. please consult chapter on parameters in the Crystal Reports User Guide: · Chapter 16 of the CR version 7 User Guide · Chapter 22 of the CR version 8 User Guide. you can create ranged parameters.#13 How to Display a Date Range Parameter on a Report Solution NOTE: In Crystal Reports version 7 or higher. This means that instead of creating both a start and end parameter. regardless of whether thos dates are in the database. The text object now appears similar to this: [{?pm-startdate} to {?pm-enddate}] This displays the date range that was entered for this report. please see http://www. To display a parameter-based date range for a report. Training: Learn more about Crystal Reports .Report Design. click 'Text Object'. On the 'Insert' menu. 4. Press the spacebar to insert a space in the text object. To learn how to use ranged parameters. 3. On the 'Insert' menu.

How to Suppress a Blank Subreport and then Suppress the Section 1. Select the 'Suppress Blank Subreport' check box. 6. select the 'Suppress Blank Section' check box.com/library/kbase/articles/c2011893.asp The information in the article refers to: Crystal Reports 9 Applies to: Reported version and higher 'Suppress Blank Subpreport' option Displaying subreports Suppress blank section Synopsis In Crystal Reports (CR) 9. Click 'OK' to exit the Section Expert dialog box. how is a subreport suppressed if it contains no data? Also. Click 'OK' to exit the Format Editor dialog box. 2. 7. 54 Business Objects • Crystal Reports Secrets . Right-click the section containing the subreport and select 'Section Expert'. To suppress a section that contains a blank subreport. select the 'Suppress Blank Subreport' check box. Right-click the subreport object and select 'Format Subreport'.businessobjects. This feature is new to version 9 of Crystal Reports. 4. 5. 3. how is a section suppressed if it contains a blank subreport? Solution To suppress a blank subreport. click the Subreport tab. In the Section Expert dialog box. select the 'Suppress Blank Section' check box.#14 How to suppress a blank subreport #14 How to suppress a blank subreport http://support. In the Format Editor dialog box.

Training: Learn more about subreports in Crystal Reports.crystaldecisions. a blank subreport cannot be suppressed.com/training 55 Business Objects • Crystal Reports Secrets . a section containing a blank subreport cannot be suppressed.#14 How to suppress a blank subreport Upon selecting the 'Suppress Blank Subreport' and 'Suppress Blank Section' check boxes. For more information on how to workaround this issue in CR 8. refer to our knowledge base article c2005853.5 and earlier. Background In Crystal Reports 8. the subreport and section will not display on the main report when no data is contained in the subreport.5 and earlier. Therefore. The blank subreport is recognized as an object in the section. Refer to 'Courses & Schedules' at: http://www.

expand 'References'.#15 How to deploy an application that uses Crystal Reports and VS .Crystal Reports 9 .NET #15 How to deploy an application that uses Crystal Reports and VS .1.CrystalDecisions.com/library/kbase/articles/c2013175.CrystalReports. The Crystal Reports managed components include: . select 'Properties' and check the version property. your application uses Crystal Reports for Visual Studio .Crystal Reports 10 To do this.CrystalDecisions. The assembly version must be the same for all the Crystal Reports managed components referenced in the solution.CrystalDecisions.NET 2003 .NET.Forms. right-click on a Crystal Reports managed component.NET 2002 .NET? http://support.asp The information in the article refers to: Crystal Reports for Visual Studio 9 Applies to: Reported version only Application Deployment Runtime Files Synopsis How do you deploy an application that uses Crystal Reports and Visual Studio . check the assembly version of the Crystal Reports managed components.NET? Solution Before you deploy an application that uses Crystal Reports and Visual Studio .3300.CrystalDecisions. In your Visual Studio .Web .Engine .Crystal Reports for Visual Studio . · If your Crystal Reports managed assemblies are version 9.Crystal Reports for Visual Studio .NET you must confirm the version of Crystal Reports being used with Visual Studio .Windows.Shared .Reportsource . The possible versions are: . 56 Business Objects • Crystal Reports Secrets .NET 2002.NET 'Solution Explorer'.businessobjects.CrystalDecisions.

Ensure that the assembly version of the Crystal Reports managed components is 9.pdf". Go to http://support.5000. · If your Crystal Reports managed assemblies are version 9.NET · If your Crystal Reports managed assemblies are version 9.com/search and download "crnet_deployment. 3. To deploy an application that uses Crystal Reports for Visual Studio .pdf". your application uses Crystal Reports for Visual Studio .businessobjects.3300.2.#15 How to deploy an application that uses Crystal Reports and VS .1. 2. 2. To deploy an application that uses Crystal Reports for Visual Studio . your application uses Crystal Reports 10.1.NET 2003.com/search and download "crnet_deployment.5000. Ensure that the assembly version of the Crystal Reports managed components is 9. 3. · If your Crystal Reports managed assemblies are version 10. Go to http://support.NET 2002 1.3300.0. Open Crnet_deployment.businessobjects. your application uses Crystal Reports 9.3300.pdf and refer to the 57 Business Objects • Crystal Reports Secrets .pdf and refer to the 'Crystal Reports Bundled Version with VS 2003' section.pdf and refer to the 'Crystal Reports Bundled Version with VS 2002' section.businessobjects. Go to http://support. Open Crnet_deployment.3300. 3. Ensure that the assembly version of the Crystal Reports managed components is 9.2.pdf". 2.1. To deploy an application that uses Crystal Reports 9 1. Open Crnet_deployment.com/search and download "crnet_deployment.NET 2003 1.

To deploy an application that uses Crystal Reports 10 1. Training: Learn more about Crystal Reports.crystaldecisions.0.com/training 58 Business Objects • Crystal Reports Secrets . Ensure that the assembly version of the Crystal Reports managed components is 10.3300. 2.#15 How to deploy an application that uses Crystal Reports and VS .com/search and download "deploying_cr10_net.pdf". Refer to 'Courses & Schedules' at: http://www. Go to http://support.NET 'Crystal Reports 9 Full Version with VS2002 or VS2003' section.businessobjects.

What is Unicows.com/search and download rdc9_deployment. Search for this file at: http://support.zip.businessobjects. Unicows.com/training 59 Business Objects • Crystal Reports Secrets .crystaldecisions.businessobjects.x and ME operating Unicows.dll is contained in the RDC 9 merge modules.dll and where can you find it? Solution NOTE: Windows 9.dll as a dependency file for the Report Designer Component (RDC) and Crystal Print Engine API.chm) lists Unicows.businessobjects.x and ME are not supported platforms for Crystal Reports (CR) 10 and later.com/search and download Cr9rdcmergemodules. For information on deploying an RDC 9 application.pdf.dll is not supported for the Windows 9.asp The information in the article refers to: Crystal Reports 9 Applies to: Reported version only Unicode runtime Windows 9x/ME Synopsis The Crystal Reports (CR) 9 Developer Runtime Help (Runtime. Therefore. and XP already provide Unicode support). go to http://support.dll and where can you find it? http://support. 2000.dll and where can you find it? #16 What is Unicows.businessobjects.dll is a wrapper to provide Unicode support for Windows 9x and ME (Windows NT.com/search Training: Refer to 'Courses & Schedules' at: http://www.com/library/kbase/articles/c2011871.#16 What is Unicows. The Unicows. To download the RDC 9 merge modules. go to http://support.

NET application #17 How to change the data source using CR for VS .NET --------------------- // Helper method that iterates through all tables // in a report document bool ApplyLogon(ReportDocument cr.businessobjects. ConnectionInfo ci) { TableLogOnInfo li.NET as the reporting development tool. How do you change the database and server in a report at runtime? For example.com/library/kbase/articles/c2011464.asp The information in the article refers to: Crystal Reports for Visual Studio .#17 How to change the data source using CR for VS .NET Applies to: Reported version only Database connectivity Change Database and Server Synopsis An application uses Crystal Reports for Visual Studio .C# . if a report is designed against the 'pubs1' database and the 'server1' server. 60 Business Objects • Crystal Reports Secrets . copy one of the following code samples into your class (use the logon method defined in the code to change the database and server): --------------------. how can you change the database to 'pubs2' and the server to 'server2'? Solution To change the database and server at runtime.NET application http://support.

and not under the User DSN.") > 0) { tbl.Substring(tbl.ConnectionInfo = ci. ensure you iterate through each subreports. } else return(false) } return(true). check // logon credentials if (tbl.IndexOf(".Location = tbl.Tables) { li = tbl. // for each table apply connection info foreach (Table tbl in cr.LastIndexOf(". } else tbl. } // The Logon method iterates through all tables 61 Business Objects • Crystal Reports Secrets . tbl.NET application CAUTION: • When using ODBC.mdb).Location. use the ApplyLogon method instead of the Logon method. • The Logon method cannot change database file name when using DAO (Microsoft Access File/.NET SDK or Report Designer Component (RDC).Location.TestConnectivity()) { // drop fully qualified table location if (tbl.Location. li.LogOnInfo. The DSN should be under the System DSN. // check if logon was successful // if TestConnectivity returns false.#17 How to change the data source using CR for VS . • It is not possible to use the CR for VS .ApplyLogOnInfo(li).Location = tbl. When using the ApplyLogon method. the DSN name is the server name.Location.NET SDK to change a report from using SQL Authentication to Windows Authentication.Database.") + 1). This functionality is available through the Report Application Server (RAS) . or vice versa. • If you have a subreport that connects to a different database or server than your main report.

} ---------------------.ReportDefinition.#17 How to change the data source using CR for VS . ' check logon credentials If (tbl.SubreportName).OpenSubreport(subObj.LogOnInfo li.DatabaseName = db.LastIndexOf(". } } return (true).TestConnectivity()) Then 'drop fully qualified table location If (tbl.Location. ci.Location.SubreportObject) { subObj = (SubreportObject)obj. if (!ApplyLogon(cr.Tables li = tbl. ci.ReportObjects) { if (obj. ByVal ci As ConnectionInfo) As Boolean Dim li As TableLogOnInfo Dim tbl As Table ' for each table apply connection info For Each tbl In cr. SubreportObject subObj.ServerName = server.Password = pass. string id.NET --------------------- Function ApplyLogon(ByVal cr As ReportDocument.") > 0) Then tbl.Location. if (!ApplyLogon(cr.NET application bool Logon(ReportDocument cr. string pass) { ConnectionInfo ci = new ConnectionInfo().IndexOf(". ci)) return(false).ConnectionInfo = ci tbl.Database. string db. ci)) return (false). ci. string server.Location = tbl.Substring(tbl. foreach (ReportObject obj in cr. ci.ApplyLogOnInfo(li) ' check if logon was successful ' if TestConnectivity returns false.UserID = id.") + 1) 62 Business Objects • Crystal Reports Secrets .Kind == ReportObjectKind.VB .

ReportDefinition. SubreportObject) If Not (ApplyLogon(cr.ReportObjects If (obj. ByVal server As String.NET application Else tbl.Kind = ReportObjectKind. ByVal id As String.OpenSubreport(subObj.SubreportObject) Then subObj = CType(obj.#17 How to change the data source using CR for VS . ci)) Then Return False End If End If Next Return True End Function 63 Business Objects • Crystal Reports Secrets . ByVal db As String.ServerName = server ci.Location End If Else Return False End If Return True Next End Function 'The Logon method iterates through all tables Function Logon(ByVal cr As ReportDocument. ByVal pass As String) As Boolean Dim ci As New ConnectionInfo() Dim subObj As SubreportObject ci.SubreportName).Password = pass If Not (ApplyLogon(cr.UserID = id ci.Location = tbl. ci)) Then Return False End If Dim obj As ReportObject For Each obj In cr.DatabaseName = db ci.

#17 How to change the data source using CR for VS .com/training 64 Business Objects • Crystal Reports Secrets .NET application Training: Refer to 'Courses & Schedules' at: http://www.crystaldecisions.

#18 How to pass Database logon info to a Crystal Report at runtime in VB .NET

#18 How to pass Database logon info to a Crystal Report at runtime in VB .NET http://support.businessobjects.com/library/kbase/articles/c2010371.asp

The information in the article refers to:
Crystal Reports for Visual Studio .NET

Applies to:
Reported version only Logon Information TableLogonInfo

Synopsis:
A VB .NET application uses Crystal Reports for Visual Studio .NET as the reporting development tool. How do you pass database logon information to a Crystal Report at runtime in this VB .NET application?

Solution:
To pass logon information to a Crystal Report at runtime, use the following code sample:
<VB .NET> -----------

Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Dim crtableLogoninfos As New TableLogOnInfos() Dim crtableLogoninfo As New TableLogOnInfo() Dim crConnectionInfo As New ConnectionInfo() Dim CrTables As Tables Dim CrTable As Table Dim TableCounter 'If you are using a Strongly Typed report (Imported in 'your project) named CrystalReport1.rpt use the 'following: Dim crReportDocument As New CrystalReport1()

65

Business Objects • Crystal Reports Secrets

#18 How to pass Database logon info to a Crystal Report at runtime in VB .NET

'If you are using a Non-Typed report, and loading a report outside of the project, use the 'following: Dim crReportDocument As New ReportDocument() crReportDocument.Load("c:\myReports\myReport.rpt") 'Set the ConnectionInfo properties for logging on to the Database 'If you are using ODBC, this should be the DSN name NOT the physical server name. If 'you are NOT using ODBC, this should be the physical server name With crConnectionInfo .ServerName = "DSN or Server Name" 'If you are connecting to Oracle there is no DatabaseName. Use an empty string. 'For example, .DatabaseName = "" .DatabaseName = "DatabaseName" .UserID = "Your User ID" .Password = "Your Password" End With 'This code works for both user tables and stored procedures. Set the CrTables to the Tables 'collection of the report CrTables = crReportDocument.Database.Tables 'Loop through each table in the report and apply the LogonInfo information For Each CrTable in CrTables CrTableLogonInfo = CrTable.LogonInfo CrTableLogonInfo.ConnectionInfo = crConnectionInfo CrTable.ApplyLogOnInfo(crtableLogoninfo) 'If your DatabaseName is changing at runtime, specify the table location. 'For example, when you are reporting off of a Northwind database on SQL server you 'should have the following line of code: crTable.Location = "Northwind.dbo." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1) Next 'Set the viewer to the report object to be previewed. CrystalReportViewer1.ReportSource = crReportDocument

66

Business Objects • Crystal Reports Secrets

#18 How to pass Database logon info to a Crystal Report at runtime in VB .NET

<C# .NET> -----------

using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; private CrystalReport1 crReportDocument = new CrystalReport1 (); private Database crDatabase; private Tables crTables; private Table crTable; private TableLogOnInfo crTableLogOnInfo; private ConnectionInfo crConnectionInfo = new ConnectionInfo (); //Setup the connection information structure to log on to the data source for the report. // If using ODBC, this should be the DSN. If using OLEDB, etc, this should be the physical //server name crConnectionInfo.ServerName = "DSN or Server Name"; // If you are connecting to Oracle there is no // DatabaseName. Use an empty // string i.e. crConnectionInfo.DatabaseName = ""; crConnectionInfo.DatabaseName = "DatabaseName"; crConnectionInfo.UserID = "Your UserID"; crConnectionInfo.Password = "Your Password"; // This code works for both user tables and stored procedures //Get the table information from the report crDatabase = crReportDocument.Database; crTables = crDatabase.Tables; //Loop through all tables in the report and apply the connection information for each table. for (int i = 0; i < crTables.Count; i++) { crTable = crTables [i]; crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectionInfo; crTable.ApplyLogOnInfo(crTableLogOnInfo);

67

Business Objects • Crystal Reports Secrets

" + crTable.Location = "Northwind. CAUTION: • If you're using a web application make sure that. • If you are changing database at runtime.dbo. and make sure ASPNET account has enough access to the database. For example.Substring(crTable.Location.location = "databaseName.tablename" • If you are reporting off of an Access Database.LastIndexOf (".ReportSource = crReportDocument. You can either specify the tablename only or the fully qualified tablename such as: crTable.dbo.DatabaseName = "C:\mydatabase\mydata. then you only need to specify either the ServerName or DatabaseName to the ConnectionInfo Object depending on how you are connecting to Access.NET //If your DatabaseName is changing at runtime.mdb" End With 68 Business Objects • Crystal Reports Secrets . you do not specify or call the DataBind in your code as this will nullify the code above.ServerName = "C:\mydatabase\mydata.Location.#18 How to pass Database logon info to a Crystal Report at runtime in VB . specify the table location. please refer to the Knowledge base article c2010867 (For Windows 2000) or c2013758 (Windows 2003 server (IIS6)).mdb" End With • If you are connecting to Access via OLEDB. For example. and the application directories. reports.") + 1) } //Set the viewer to the report object to be previewed. If the above code still results in a LogOn Failure in a Web application (ASP. if you are connecting to Access through ODBC. then you just need to set the DatabaseName for the ConnectionInfo object as the following: With crConnectionInfo . when //you are reporting off of a Northwind database on SQL server you should have the following //line of code: crTable. crystalReportViewer1.NET). it is important that you specify the table location after you apply logon information (this is a case sensitive property). then you just need to set the ServerName: With crConnectionInfo .

crystaldecisions.#18 How to pass Database logon info to a Crystal Report at runtime in VB .NET Training: Refer to 'Courses & Schedules' at: http://www.com/training 69 Business Objects • Crystal Reports Secrets .

Display the report.Add a parameter field to the ParameterFieldDefinitions collection.businessobjects.Create a record selection formula that includes the parameter field.Add a table from a Native connection to Microsoft Access. Solution This tutorial assumes that the developer has prior knowledge of Microsoft Visual Basic. please visit http://www. and the Report Designer Component. (RCAPI Method: 'AddFieldObject') . 1. Crystal Reports. (RCAPI Method: 'Add') .com/k base All Runtime Report Creation functionality requires licensing. (RCAPI Method: 'Add') . The following procedure and sample code creates an application that demonstrates the RCAPI methods outlined in the Synopsis. The 'References' dialog box appears. This article demonstrates how to: . For more information. On the 'Project' menu in Microsoft Visual Basic click 'References'.asp The information in the article refers to: Crystal Reports.crystal decisions. 70 Business Objects • Crystal Reports Secrets .com/library/kbase/articles/c2007184. Report Designer Component 8 Applies to: Reported version and higher Report Creations API Creating a Parameter field at runtime Including the Parameter field in a record selection formual NOTE: For more articles on using the Report Designer Component's Report Creation API search on the keyword 'RCAPI' at http://support.crys taldecisions.Add database fields to the report. .Create a report at runtime (RCAPI Method: 'NewReport') .com/pro ducts/crystalreport Synopsis This article is part of a series of Knowledge Base articles that demonstrate the Report Creation API (RCAPI) available in the Report Designer Component for Crystal Reports Version 8 Developer Edition.#19 How to create a report and add a parameter field using Report Creation API #19 How to create a report and add a parameter field using Report Creation API http://support.

Call AddParameterField 71 Business Objects • Crystal Reports Secrets . Click 'OK' to save the changes. select the 'Crystal Report Viewer' check box and then click 'Apply'. then makes calls to routines 'that will setup the report and finally display the report in the Crystal Report Viewer control. 4. This adds the CRViewer icon to the Microsoft Visual Basic toolbar. 7. Call AddToDetails 'Calling a routine that will add a parameter field to the ParameterFieldDefinitions collection. Once you have inserted the code. Click 'OK' to save the changes. In the dialog box click 'Controls'.Application 'Create a new report Set crReport = crApplication. 2. 3.#19 How to create a report and add a parameter field using Report Creation API NOTE: For more information on the RCAPI refer to the 'Seagate Crystal Reports 8 Technical Reference Guide'. on the 'Run' menu. On the Microsoft Visual Basic toolbar double-click 'CRViewer'. click 'Components'. 'and include the parameter in a record selection formula. click 'Start' to run the application. Double-click 'Form1' to open the 'Code' module. Option Explicit 'RDC Runtime Objects used in this sample. Dim crApplication As CRAXDRT. The Crystal Report Viewer is added to the form. The 'Components' dialog box appears. The guide can be found in the Docs folder of the Crystal Report 8 installation CD. Insert the 'Sample RDCAPI code' in the code module. '*********************************************** Private Sub Form_Load() 'Create an instance of the RDC engine Set crApplication = New CRAXDRT. On the 'Project' menu. In the dialog box select the 'Crystal Report 8 ActiveX Designer Run Time Library' check box.Report '*********************************************** 'The Form_Load event creates an instance of the RDC engine. 6. 5.NewReport 'Calling a routine that will add a database connection for the report Call AddDatabase 'Calling a routine that will add objects to the Detail section.Application Dim crReport As CRAXDRT.

ReportSource = crReport 'Display the report in the Crystal Report Viewer CRViewer1.#19 How to create a report and add a parameter field using Report Creation API 'Set the Report Viewer control to a report to view CRViewer1.Path & "\xtreme.Database. 'The database resides in the same directory as the application ' sDatabasePath = App. Which arguments are passed will depend on the type of 'database.Add() method to add the database table to the report. 'Add the 'Customer' table crDBTables.Section Dim crFieldObject As CRAXDRT. the type of table and the type of connection. sTableName End Sub '*********************************************** 'The AddToDetails () routine is used to add objects to the Detail section. Xtreme. '*********************************************** Public Sub AddDatabase() 'Variables used to setup the Database connection Dim crDBTables As CRAXDRT. '*********************************************** Public Sub AddToDetails() Dim crSection As CRAXDRT.DatabaseTables Dim sDatabasePath As String Dim sTableName As String 'Get the Tables collection because it has the Add() method needed 'to add a connection to the report Set crDBTables = crReport.MDB. In this sample the 'Customer' table is being added. two 'fields from the 'Customer' table are added.ViewReport End Sub '*********************************************** 'The AddDatabase() routine is used to add a native database connection to the sample 'database.Tables 'Set the values for the connection variables The full path and name of the Access database. There are several optional 'arguments for the Add method.FieldObject 72 Business Objects • Crystal Reports Secrets .Add sDatabasePath.mdb" 'The name of the Access table sTableName = "Customer" 'Use the . In this case.

'crCurrencyField 73 Business Objects • Crystal Reports Secrets .fieldname 'The Left and Top parameters are passed as integers to position the field Set crFieldObject = crSection.#19 How to create a report and add a parameter field using Report Creation API '****Add database fields and the formula field to the Details section***** 'Since we are working with the Details section of the report.Item("D") '**Add the 'Customer Name and 'Last Year's Sales' fields to the details section** 'Set a Field object to the AddFieldObject method of the Detail Section 'The Field parameter is set to the table.Sections. 0) Set crFieldObject = crSection.ParameterFields 'Add a parameter field to the ParameterFieldDefinitions Collection The ParameterName 'parameter is set to the name of the new parameter The ValueType parameter specifies the 'value type to be passed to the parameter crParameterFields.Last Year's Sales}". 0) End Sub '*********************************************** 'The AddParameterField () routine is used to add a parameter field to the 'ParameterFieldDefinitions collection. 3720. The default values for the parameter field will be set and 'the parameter will be included in a record selection formula '*********************************************** Public Sub AddParameterField() Dim crParameterFields As CRAXDRT.Add "Sales Maximum Value".AddFieldObject("{Customer.ParameterFieldDefinitions 'Since we are adding a formula field to the ParameterFieldDefinitions collection we need to get 'the ParameterFields from the report object Set crParameterFields = crReport. we need to get the 'D' section of 'the report.AddFieldObject("{Customer.Customer Name}". 600. Set crSection = crReport.

'*********************************************** Private Sub Form_Resize() With CRViewer1 .Width = Me.Left = 0 .DiscreteOrRangeKind = crDiscreteValue .AddDefaultValue 50 .AddDefaultValue 500 .AddDefaultValue 1000000 .AddDefaultValue 100000 .AddDefaultValue 150000 .AddDefaultValue 10000 . The default 'values set previously will be available to the user to select the name of the parameter field in 'the recordslection formula will follow this format: '{? + The name of the new parameterfield + } 'crReport.EnableMultipleValues = False End With 'Pass a record selection formula to the report The record selection formula contains the newly 'created parameter When the report is run the parameter will prompt the user.AddDefaultValue 25000 .AddDefaultValue 500000 .ParameterFields(1) .Height = Me.AddDefaultValue 200000 .Top = 0 .#19 How to create a report and add a parameter field using Report Creation API 'With the new parameter field set the default values Set the Value to be a single discrete 'value and do not allow multiple values This is the first parameter field created in the report so 'we access the first item in the ParameterFieldDefinitions collection With crReport.AddDefaultValue 50000 .ScaleWidth .ScaleHeight End With End Sub '*********************************************** 'The Form_Unload event is used to clean up the objects 74 Business Objects • Crystal Reports Secrets .RecordSelectionFormula = "{Customer.Last Year's Sales} < {?Sales Maximum 'Value}" End Sub '*********************************************** 'The Form_Resize event is used to size the Crystal Report 'Viewer control to the size of the Parent form (Form1).AddDefaultValue 250000 .

com/training 75 Business Objects • Crystal Reports Secrets .#19 How to create a report and add a parameter field using Report Creation API 'used by the sample application.crystaldecisions. '*********************************************** Private Sub Form_Unload(Cancel As Integer) 'Destroy the Report object Set crReport = Nothing 'Destroy the Application object Set crApplication = Nothing End Sub Training: Refer to 'Courses & Schedules' at: http://www.

and press the F1 key.asp 76 Business Objects • Crystal Reports Secrets . The common ones are: · Searching for "Crystal Reports" in the VS . Documentation is available online at the Microsoft Developer Network (MSDN) web site and is also bundled with VS .asp?frame=true Microsoft Visual Studio .asp The information in the article refers to: Crystal Reports for Visual Studio .#20 Crystal Reports for Visual Studio .NET documentation http://support.NET as part of MSDN. The following link leads directly to the Crystal Reports for VS .NET You can also find CR for VS . Documentation is accessible through a variety of methods in VS .NET documentation #20 Crystal Reports for Visual Studio . A tab appears in the VS.NET (VS .NET.com/library/kbase/articles/c2010837.NET)? Solution Crystal Reports documentation is included as part of the VS .com/services/training/crystalreports.NET resources on the Business Objects support site.businessobjects.com/library/?url=/library/enus/crystlmn/html/crconcrystalreports. · ontext sensitive help: Click the insertion point on a Crystal property method or object in the VS .NET IDE with documentation on what code is covered by the insertion point http://www.NET documentation.NET documentation in the MSDN Library: MSDN Website: http://msdn.NET documentation index.NET code editor.microsoft.businessobjects.NET Applies to: Reported version only Documentation Synopsis Where can you find documentation or help files for Crystal Reports for Visual Studio .

#20 Crystal Reports for Visual Studio .com/search Training: Refer to 'Courses & Schedules' at: http://www.businessobjects.businessobjects.com/library/docfiles/cps10/docs_en.businessobjects.com/training 77 Business Objects • Crystal Reports Secrets .asp · Download VS .NET white papers by searching for "crnet*" at http://support.NET documentation Business Objects Support Site · Download .NET sample applications at http://support.NET documentation at http://support.asp · Download VS .com/fix/samplescr.crystaldecisions.

businessobjects. The comprehensive report is free of charge – download your copy by visiting www. We hope that you already feel more confident in your ability to design better reports. please visit http://www.) http://www.” (Certification Magazine’s 2003 Salary Survey.com/services/training/crystalreports. 78 Business Objects • Crystal Reports Secrets .com/training Thank you for investing the time to learn our Crystal Reports secrets.com/services/training/crystal/certification.Summary Summary: Whether you are a novice or an expert. If you have any questions. there are additional resources available to help you get more from your investment.businessobjects. we have a white paper just for you. Our customer service representatives are ready to help you. December 2003.businessobjects. please contact us. “73% of employees surveyed said certification played a significant role in career advancement. In North America call 1-866-665-4176 or contact a worldwide office. faster.asp A final tip: If you are responsible for team or organization training or if user adoption is important to you.asp You might also want to consider certification. To investigate all of the options.

SA 157-159 rue Anatole France 92309 Levallois-Perret Cedex France Tel: +33 1 41 25 21 21 Japan Business Objects Japan K. California 95134 USA Tel: +1 408 953 6000 +1 800 877 2340 Asia-Pacific Business Objects Asia Pacific Pte Ltd 350 Orchard Road #20-04/06 Shaw House 238868 Singapore Tel: +65 6887 4228 Europe. please visit our website. http://www. Africa Business Objects.com 79 Business Objects • Crystal Reports Secrets .K. Middle East.Worldwide contact information Americas Business Objects Americas 3030 Orchard Parkway San Jose. Head Office Yebisu Garden Place Tower 28th Floor 4-20-3 Ebisu.businessobjects. Shibuya-ku Tokyo 150-6028 Tel: +81 3 5720 3570 For a complete listing of our sales offices.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->