Solved

A tilde in my crystal report

Posted on 2004-11-01
905 Views
Last Modified: 2012-06-21
I am passing a string to my crystal report from a HTML form. The string contains a lastname,  firstname, for example
"Doe,  John" . On my Crystal Report my parameter looks like Doe~ John. Is there a way to fix this so that Crystal will see my string as "Doe,  John" on the report. If I type the value directly into the report, the parameter displays correctly. Thanks.
0
Question by:techdl
    7 Comments
     
    LVL 26

    Expert Comment

    by:Kurt Reinhardt
    Assuming that you're trying to format the text of a string field that appears on the report, not a parameter field the simplest method is to use the REPLACE function (depending on your version of CR):

    Replace({table.field},'~ ',', ')

    If you're trying to do something more complex, please reply and we'll assist as best we can :-)

    ~Kurt
    0
     

    Author Comment

    by:techdl
    It's a parameter field. I am currently using CR 8.5. Will the same answer apply to a parameter field?
    0
     
    LVL 26

    Expert Comment

    by:Kurt Reinhardt
    When you say:

    "On my Crystal Report my parameter looks like Doe~ John"

    what do you mean?  Are you displaying the parameter as a field on the report, or do you mean that the tilde is processed as part of your record selection criteria?  What is the root of the issue?

    ~Kurt
    0
     

    Author Comment

    by:techdl
    In my web form I have the following:

    <select name="promptex-@ApproverName" style="FONT-FAMILY:monospace" id="ApproverName">
                        <option value ="Doe1,  John">Doe1, John</option>
                        <option value ="Doe2,  John">Doe2, John</option>
                        <option value ="Doe3,  John">Doe3, John</option>


    When I select a name from my option list, it is passed to my report as a parameter. On my report I am trying to display data based on the @ApproverName, in addition to showing @ApproverName.

    Instead of Crystal comparing @ApproverName as Doe1, John
    Crystal compares the name from the web form as Doe1~ John. Something is replacing the , with a ~
    As a result  @ApproverName displays as Doe1~ John on the Crystal Report, and my data is not coming up as a result of the incorrect parameter. Hope this helps clarify. Thanks.
    0
     
    LVL 26

    Expert Comment

    by:Kurt Reinhardt
    You can use the replace function in your record selection criteria, but it will prevent the data from being passed to the database.  Please post your record selection criteria and we'll see what we can do to get you the right data (hopefully efficiently).

    ~Kurt
    0
     

    Author Comment

    by:techdl
    Below is the condition: I am trying to compare Doe1, John in the table, to the parameter Doe1, John being passed from the web form.

    {tblName.ApproverName} = {?@ApproverName}

    Hope this is what you were looking to see.
    0
     
    LVL 26

    Accepted Solution

    by:
    in general, I'd say you can use the following:

    {tblName.ApproverName} = Replace({?@ApproverName},'~ ',', '), but it's not very efficient.  What db are you using and is this report based upon a stored procedure?

    If you're using a SQL-based db (Oracle, SQL Server, etc..), then you could use something like the following (more syntax, but more efficient db processing):

    (
    If
      Not IsNull({?@ApproverName})
    Then
      Replace({?@ApproverName},'~ ',', ')
    Else If
      IsNull({?@ApproverName})
    Then
      False
    )

    Basically this code checks to see if the parameter is NULL.  If it is, nothing is returned.  If it isn't, then it changes the tilde to a comma.  In general, MOST Crystal functions won't be passed to the database for processing unless you can embed them in other special fields (like Switch, Choose or IIF) or within an IF-THEN-ELSE IF boolean statement (like above).

    ~Kurt
     
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    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…
    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…
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    910 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

    14 Experts available now in Live!

    Get 1:1 Help Now