How to Create a Formula in Crystal Reports XI,VB.NET Crystal Reports Formula Fields

Formulas serve many purposes and in my example I am going to show you how I am able to combine to fields from a database to create one complete field. This How-To assumes that you have worked through my previous How-To article of creating a simple report. It is this simple report I am going to use.
  1. Open Crystal Reports XI
  2. Step 2
    Open the simple report you created rfom my previous how-to article.
  3. Step 3
    Right click
     
    Right click
    On the field explorer, right click on Formula Fields.
  4. Step 4
    New
     
    New
    Select "New" from the popup menu.
  5. Step 5
    FullName
     
    FullName
    Give your formula the name, "FullName".
  6. Step 6
    Ok
     
    Ok
    Click the ok button.
  7. Step 7
    Expand
     
    Expand
    The formula workshop window will appear. In here we are going to combine the last name database field, with the first name database field to create the formula "FullName." Expand the window that displays the database fields by clicking on the [+] plus sign. See image.
  8. Step 8
    Get LastName
     
    Get LastName
    Double click the "LastName" field. This will put it in the formula editor area.
  9. Step 9
    Concatenate
     
    Concatenate
    Add the amerpsand (&) symbol and then in quotations a comma followed by a space and then another ampersand. See the picture for how it looks. This will help separate the last name from the first name with a comma. The ampersand symbols concatenates two strings together.
  10. Step 10
    Get Firstname
     
    Get Firstname
    Double click on the first name field to add it to the formula editor.
  11. Step 11
    Check for Errors
     
    Check for Errors
    Check to make sure the formula does not have any errors in it by clicking the (x+2) button with the green checkmark underneath.
  12. Step 12
    No Errors
     
    No Errors
    You will should receive the message box as shown in the picture. If you receive a different message it means there is an error. Go back through the steps, follow the pictures and try again before you continue.
  13. Step 13
    Save and Close
     
    Save and Close
    Click the "Save and Close" button.
  14. Step 14
    Formula Created
     
    Formula Created
    The formula has been created and exists in the Field Explorer window as shown in the picture.
  15. Step 15
    Formula added to report
     
    Formula added to report
    Add the formula to the report by double clicking the formula name, dragging your mouse to the report and clicking the mouse button to drop it in the details section. Your report should now look like the picture.
  16. Step 16
    Final Report
     
    Final Report
    Press the "F5" key to see how the report with the formula looks. Click the Ok button if you get the message box asking if you wish to refresh the data. The picture shows the final results.

No comments:

Post a Comment

Please Provide your feedback here