Solved

Formatting punctuation in Crystal Reports

Posted on 2006-07-12
3
321 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 34

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

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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 …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

13 Experts available now in Live!

Get 1:1 Help Now