Solved

Formatting punctuation in Crystal Reports

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

724 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