PARTNER

Senin, 31 Mei 2010

Number of Records by Category

Using the keyword "global" to create custom record number

Okay. Let's open the crystal report application and follow these steps :
  1. Create a new report, take the datasource from the table named "Products" and "Categories"
  2. Click on icon "Group Expert" on the toolbar so the window titled "Group Expert" appear. In the box "Available Fields:", choose field "categories.CategoryID" and insert it into box "Group By", then click "OK".
  3. Inside the window "Field Explorer", Right click on "x+1 Formula Fields" and then choose "New" from the pop-up menu. When the window to input formula name appear, type "CategoryName" inside the available textbox and then click "OK".
  4. The window titled "Formula Editor" will then displayed, choose the "Basic Syntax" from the combobox at the top side and type the following command inside the formula editor :

    formula = "Category : " & {categories.CategoryName}

    Then place the above formula into the Group Header section 
  5.  Create a new formula named "RecordNo" for numbering the record as the step number 3 above, and then type the following code into the formula editor :
    Global RecordNo as number
    WhilePrintingRecords
    RecordNo = RecordNo + 1
    formula = RecordNo

    Then place the above formula into the detail section, on the left-most column
  6. Create a new formula named "ResetRecordNo" to reset the record numbering by using the following code :
    Global RecordNo as number
    WhilePrintingRecords
    RecordNo = 0
    formula = RecordNo

    Then place the above formula into the Group Header section and make this formula invisible. The way to make an object/field invisible on the report is by right click on the object and choose "Format Field" from the pop-up menu. When the window "Format Editor" appear, click on the "Common" tab and fill the checkbox labeled "Suppress", and then click "OK". After suppressing an object, the object will be gray.
  7. Okay. The work on designing report is finished.

    Source : http://yudio.net/post/Using-the-keyword-global-to-create-custom-record-number.aspx

Share:

0 komentar:

Posting Komentar

Blog Archive

Blogger templates