?
Solved

Formatting punctuation in Crystal Reports

Posted on 2006-07-12
3
Medium Priority
?
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
dkDeveloper earned 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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 …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

777 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