Solved

Formatting punctuation in Crystal Reports

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

20 Experts available now in Live!

Get 1:1 Help Now