stu nicholls dot com | menu - Professional dropdown #3

To Generate Report Using Selection Formula at Run time

The criteria for records which you want to display can be specified using this formula. Fox example you want to display those students who have scored marks equal to 100, then you can specify it in the formula.

  1. Add a Form
  2. Add a Crystal Report Item and from the resulting screen select Blank report which is shown in Fig.19.

  3. Click on OK you will get a Report Screen as shown in Fig. 20

  4. Right Click on to Database Fields present in the Field Explorer. You will get a Screen as shown in Fig. 21.

  5. Click on to Database Expert then you will get a Screen as shown in Fig.22.

  6. Expand Create New Connection, then Click on to OLE DB then you will get a resulting screen and from there select Microsoft OLE DB Provider for SQL Server as shown in Fig. 23. Then Click on to Next you will get a screen as shown in Fig. 24.


  7. Now here check the Integrated Security check box. Then Enter the Server name and select the Database. Then Click on to Next you will get the screen as shown in Fig. 25.

  8. Double Click on to Add Command; you will get a screen as shown in Fig. 26.

  9. Type the query as shown in Fig. 27.

  10. Click on to OK you will get the screen as shown in Fig. 28.

  11. Click on to OK and from the database fields in the field explorer select the database fields which is shown in Fig 29.

  12. Now drag the various fields and place them in the Details section of the report as shown in fig. 30. Appropriate header will be automatically added.

  13. Now add the Selection formula

  14. Right click in the Report Designer then click on to Report and then click on to Selection formula and click on to Record shown in Fig. 31.

  15. To give a condition to display all the records which satisfies a specific condition, Double Click on to Marks under Command you will get (Command.Marks) then give the condition for example if you want to display only those records which has Marks as 100 then give =100, so your final formula is shown as (Command.Marks) = 100 which is shown in Fig. 32.

  16. Save and close, then Run the application. You will get only those Records displayed whose Marks field has value as 100.

Steps<< Previous    Next>>Passing Parameters


comments powered by Disqus
Footer1