Professional.Crystal.Reports.for.Visual.Studio..NET [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional.Crystal.Reports.for.Visual.Studio..NET [Electronic resources] - نسخه متنی

David McAmis

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید



























Creating Record Selection Formulas


Record selection is a key component of most reports, for it is here that the results are filtered to show only the information required. In Chapter 2, we had a first look at simple record selection, and at some of the operators that can be used to filter your report. Now that we're working with Crystal syntax, we can look at writing these formulas ourselves.

First, all record selection formulas have to be written in Crystal syntax - there is no option to use Basic syntax. This stems from the fact that Crystal Reports will take the record selection formula you create and write a SQL statement to retrieve the report results. Historically, Crystal syntax was the first type of syntax available, and most work has been done translating it to SQL. You may see Basic syntax supported in future releases, but that's up to Crystal Decisions!

To access or create record selection formulas, right-click on your report and select Report | Edit Selection Formula | Records. This should open up the following dialog box. Note that the drop-down box that enables you to switch between Crystal and Basic syntax is grayed out this time.



When working with record selection formulas, we use the same formula editor that you'd use to edit formulas that appear on your report, with one difference: a record selection formula will never have any type of output. The sole function of the record selection formula is to apply some condition against fields that appear in your report (where the condition is True, the record is returned), as shown in the examples below:


{Customer.Country} = "USA" And (Customer.Region) = "NC"

If you enter the above formula into the dialog box shown above (running a syntax check first of all by clicking on the X+2 icon), and then save and run the application, you should see the following output:


When working with a record selection formula, you have access to all of the fields, functions, and operators that are available within the formula language itself, including time periods, for instance:


{Orders.OrderDate} In MonthToDate

Best practice for record selection suggests that you only perform it on fields originating from your database. For example, imagine you have a formula in your report that translates the state or region names within the database to their 'long names' (so "CA" is shown as "California"). If you were going to create a record selection formula that used the state, you would definitely not want to use the 'long name' formula - if you did, the generated SQL statement would pull back every single record, evaluate the formula, and then use Crystal Reports' own inherent selection routines to filter the data.

On the other hand, if you were to create the record selection formula directly from the database fields, this in turn would be written to the SQL statement, and your report will run much more quickly.


/ 115