Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select statement confusion

Status
Not open for further replies.

hlb6

Technical User
Aug 2, 2013
27
US
(Select {?p_Period} [5 to 6]
case "12" :
ToText((ToNumber(Left({?p_Period},4))),0,"","")
default :
ToText((ToNumber(Left({?p_Period},4))-1),0,"",""))
&
(select {?p_Period} [5 to 6]
case "12" :
"01"
case "10", "11" :
ToText((ToNumber(Right({?p_Period},2))+1),0)
default:
"0"&ToText((ToNumber(Right({?p_Period},2))+1),0))


I am fixing reports that have been previously developed and I am not sure on this logic. I am trying to export my data out to excel and two records format way over to the right when they should be to the left with the other records ( They are in a group header)
 
The Select/Case statement is like an If-Then-Else statement. The formula above is concatenating (joining) two strings together. The first part of it, if written as an If-Then-Else would look like this:

Code:
If	{?p_Period} [5 to 6] = "12"
Then	ToText((ToNumber(Left({?p_Period},4))),0,"","")
Else	ToText((ToNumber(Left({?p_Period},4))-1),0,"","")

In simple speak, if the 5th and 6th character of the parameter string are a "1" and "2" respectively (ie, "12") do one thing otherwise do something different.

You will find in Crystal there are usually at least a couple of different ways to achieve the same result. One of the advantages of the Select/Case statement above is that you do not need to keep repeating the "If {?p_Period} [5 to 6] = " line if you need to deal with many different possibilities.

You might also find the CR Help files quite useful, so they are usually worth a look.

Hope this helps.

Cheers
Pete.
 
Thank you Pete! I find you help to be very useful - you explain things so that one can understand the question and result. [bigsmile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top