Easy Formula Question

Last post 07-01-2009 9:34 PM by WanderingEye. 3 replies.

Sort Posts:

  • Easy Formula Question

    07-01-2009, 3:41 PM
    • Member
      33 point Member
    • WanderingEye
    • Member since 02-19-2009, 11:04 AM
    • Posts 71

     Hey all,

    Quick question. On a Crystal Report I need to fill a text object based on a Report Field. For example, I have 2 fields 1 populates from the DataSet the other is just a text object. If the dataset field contains a date populate the text object with a static text string.

    There has to be an easy way to do this - right?

    Thanks!

  • Re: Easy Formula Question

    07-01-2009, 4:49 PM
    • Member
      691 point Member
    • aderegil
    • Member since 11-04-2004, 5:07 PM
    • Monterrey, Mexico
    • Posts 117

    Hello WanderingEye: 

    One option is to delegate that responsability to the data source and on the Crystal Reports just expect a field with exactly the info that you will put on the text object.

    I do not know the details about your field but you can usually choose between the two values with a CASE statement in your query:

     

    SELECT

      CASE LEN(TheColumn)

       WHEN 0 THEN ''

       ELSE 'Static text'

      END AS NewColumn

      FROM ...

    Your NewColumn field will always have the correct text to be assigned to your text object.

    Alfredo De Regil
  • Re: Easy Formula Question

    07-01-2009, 5:04 PM
    • Member
      33 point Member
    • WanderingEye
    • Member since 02-19-2009, 11:04 AM
    • Posts 71

    Aderegil - thanks for the reply. Let me explain a little more just to be sure we're on the same page.

    I have a date field that is filled from the DataSet. I also have a text object that has no corresponding record. If the database field for date is not null I want to supply a static string value to the text object.

    Can this be handled through a Formula? It appears your solution deals with DB fields only.

  • Re: Easy Formula Question

    07-01-2009, 9:34 PM
    Answer
    • Member
      33 point Member
    • WanderingEye
    • Member since 02-19-2009, 11:04 AM
    • Posts 71

    Got it.....Create a formula:

    If ToText({table.DateFiled}) <> "" Then

    "text string"

    Else

    ""

    Drag the formula into the textbox.  

Page 1 of 1 (4 items)