Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: If statements Post Reply Post New Topic
Author Message
jeramie
Newbie
Newbie


Joined: 26 Aug 2010
Online Status: Offline
Posts: 2
Quote jeramie Replybullet Topic: If statements
     Posted: 30 Sep 2010 at 7:05pm
Below is a sample of an If statement in a report that is used within my workplace.
Can sombody tell me where the numbers in the statement are defined or if they are representative of standard values in crystal and if so what they mean.
 
 
 
 
(if ({?location} = -1) then
    true
else
(
    if ({?mdLocation} = 0) then
        {cmMultipurpose.RegionID} = {?location}
    else if ({?mdLocation} = 1) then
        {cmMultipurpose.ResourceCentreID} = {?location}
    else if ({?mdLocation} = 2) then
        {cmMultipurpose.SiteID} = {?location}
    else
        true
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 01 Oct 2010 at 3:50am

{?xxx} represents a parameter value, the numbers are the values entered by the user for the value of the parameter.

Check the parameters and the name will have a prompt.  Does that help?
IP IP Logged
jeramie
Newbie
Newbie


Joined: 26 Aug 2010
Online Status: Offline
Posts: 2
Quote jeramie Replybullet Posted: 07 Oct 2010 at 11:39am
Hi lockwelle
 
thanks for that. i have been away for a week so sorry for taking so long to reply to your post.
 
I Already had a good idea how the parameter fields worked, so was more interested in what the values the parameters were being compared to represented.
I have since found out that the values are passed throughto crystal from the software wea are using but nobody knows what -1, 0, 1, 2 actually represent. i have been able to establish that -1 represents all records from a given database column but as to what the others mean, who knows.
 
Most of the reports use this -1, 0, 1, 2, etc as input for parameters but when using the front end the user selects text values such as Southern, northern, etc. These are then passed to crystal and translated somehow into the numbers to be compared in IF statements.
 
I may try to contact the original developer to find out how everything works but if you have any ideas in the meantime i would love to hear them.
IP IP Logged
rvink
Groupie
Groupie
Avatar

Joined: 04 Feb 2008
Location: New Zealand
Online Status: Offline
Posts: 55
Quote rvink Replybullet Posted: 07 Oct 2010 at 4:09pm
This formula returns true/false values. It looks like it is used to select/filter records for your report. Here is the same code with comments added:

if ({?location} = -1) then
    // if location parameter = -1 select all records
    true
else
(
    if ({?mdLocation} = 0) then
        // if mdLocation parameter = 0 only select
        // regions which match the location parameter 
        {cmMultipurpose.RegionID} = {?location}
    else if ({?mdLocation} = 1) then
        // if mdLocation parameter = 1 only select
        // Resource Centres which match the location parameter 
        {cmMultipurpose.ResourceCentreID} = {?location}
    else if ({?mdLocation} = 2) then
        // if mdLocation parameter = 2 only select
        // sites which match the location parameter 
        {cmMultipurpose.SiteID} = {?location}
    else
        // select all records
        true

To see what the parameter numbers mean, open the report in crystal reports, go to the field explorer, expand the "Parameter fields" and double-click on the parameters listed (should be "Location" and "mdLocation" at least). With luck you will see a list of values and descriptions which might tell you what the values mean.


Edited by rvink - 10 Oct 2010 at 2:36pm
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum