Solved

Crystal Report 2011 - String Concatenation

Posted on 2014-03-26
5
610 Views
Last Modified: 2014-04-03
Hello Experts
I am trying to write the below in the formula field but looks like its not accepting all the below as one string may be due to the IF statement? Please can someone advice how can I go about fix this?

Thanks

NumberVar d := CDbl({Lde.Day});
StringVar s := "This deed of entitlement is  made the ";
s := s & " " ;
If d >= 4 And d <= 20 Then
  s := s & " " &   ToText(d, 0, "") & "th" ;
Else If d = 1 Then
    s := s & " " &  "1st";
Else If d = 2 then
   s := s & " " &   "2nd";
Else If d = 3 then
    s := s & " " &  "3rd";
Else If d >= 24 and d <= 30 Then
     s := s & " " & ToText(d, 0, "") & "th";
Else If d = 21 Then
     s := s & " " & "21st";
Else If d = 22 Then
     s := s & " " & "22nd";
Else If d = 23 Then
     s := s & " " & "23rd";
Else If d = 31 Then
     s := s & " " & "31st";
       
s := s & " day of " & MonthName(CDbl({Laird.Month}));

s := s  & " in the year " & {Lde.Year};

s;

Open in new window


This to appear in one line as below

This deed of entitlement is  made the                        day of                           in the year          

Open in new window

0
Comment
Question by:meinIT
  • 2
  • 2
5 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
ID: 39957068
Try adding WhilePrintingRecords; as the first line of the formula.

mlmcc
0
 

Author Comment

by:meinIT
ID: 39958442
Hi mlmcc
Thanks for your picking this up for me. I have added the statement in the first line but its still giving me this error. Please see attached.
untitled.PNG
0
 
LVL 34

Assisted Solution

by:James0628
James0628 earned 250 total points
ID: 39958477
You need to remove the ";" before each Else.  A ";" is put at the end of a statement, and your if-else-if-else is one statement.  You need a ";" before the first If, and at the end of the last If (after "31st").

 FWIW, I would use Select-Case instead of the if-else-if-else.  I just find that easier to follow when you have multiple tests like this.  But that's just a personal preference.

 James
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39958872
Good catch James.  I didn't notice them and since he seemed to indicate the formula was working (not reporting an error), I didn't look too closely at the code since it seemed to be correct for what he wanted.

As written it should produce an error when saved.

mlmcc
0
 

Author Closing Comment

by:meinIT
ID: 39974568
Thank you both for your help! Apologies for the delay in getting back to you on this.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Copy/Clone an object. 9 32
Allow User To Arrange Columns At Datagridview 3 19
Exit the loop 4 40
Get size of each directory on each mapped drive 5 24
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now