Solved

Formatting punctuation in Crystal Reports

Posted on 2006-07-12
3
324 Views
Last Modified: 2010-05-18
Hello Experts,

mlmcc helped me to define a method of "stringing" together multiple values to form a sentence. Here is the formula:

WhilePrintingRecords;
Global StringVar Complaints;
Complaints := Complaints + {tblSubChiefComplaint.ChiefComplaint}& ", " ;

Obviously this will leave a comma at the end. I mitigated that result some by adding another formula after this one with a period at the end. So while it wasn't perfect grammatically, it worked. I am now implementing this procedure for another section of a report and there is nothing I can put at the end, so I'm left with either a sentence ending with a comma or having each value seperated by a period.

I wrote the following for a VB.Net app where choices are made from a listbox and concantenated together to form a sentence:

Public Function makeStringList(ByVal lb As ListBox) As String

        Dim c As Integer = lb.SelectedItems.Count
        Dim s As String
        Select Case c
            Case 0
                s = "Nothing"
            Case 1
                s = lb.SelectedItem
            Case 2
                s = lb.SelectedItems(0) & " and " & lb.SelectedItems(1)
            Case Else
                Dim i As Integer
                For i = 0 To c - 3
                    s = s & lb.SelectedItems(i) & ", "
                Next
                s = s & lb.SelectedItems(c - 2) & " and " & lb.SelectedItems(c - 1)
        End Select

        Return s

    End Function

But I can't get this to work in Crystal. Any help would be greatly appreciated.

Thanks,

Jack
0
Comment
Question by:JackW9653
3 Comments
 
LVL 5

Accepted Solution

by:
dkDeveloper earned 500 total points
ID: 17094756
Hi JackW9653,

You might want to consider using something like this...

WhilePrintingRecords;
Global StringVar Complaints;
Complaints := Complaints + {tblSubChiefComplaint.ChiefComplaint};
If Not OnLastRecord Then
    Complaints := Complaints + ", ";


That is assuming you want to append a comma for each record except the last.

Just a quick thought.
Good Luck!
dK
0
 
LVL 35

Expert Comment

by:James0628
ID: 17095350
Or you could change the formula to something like:

WhilePrintingRecords;
Global StringVar Complaints;

if Complaints = "" then
  Complaints := {tblSubChiefComplaint.ChiefComplaint}
else
  Complaints := Complaints + ", " + {tblSubChiefComplaint.ChiefComplaint};


 The difference from your original formula is that this one only puts in the "," when adding another value.

 James
0
 

Author Comment

by:JackW9653
ID: 17095748
Thanks dk,

Modified it just a tad to:

WhilePrintingRecords;
Global StringVar Complaints;
Complaints := Complaints + {tblSubChiefComplaint.ChiefComplaint};
If Not OnLastRecord Then
    Complaints := Complaints + ", "
Else Complaints := Complaints + ". ";
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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