Crystal Report XI If Statement

Posted on 2007-08-02
Last Modified: 2008-01-09
I am attempting to add a filter to a crystal report and am I looking for the correct syntex.
I have a product pick ticket that displays the product to be selcted for a specific order. I want to add a filter that will let the user know that the product is expired. I dont want to put the date on the form -just an indicator that the product is expired.  (when the product is expired, instead of the quanity to pick display a statement that lets the user know this product is expired)
I have tried varients of the syntax below, but it keeps telling me that it is looking for a statement.
end if

Crystal Reports XI Dev
Question by:GregJaroch
    LVL 28

    Expert Comment

    You can't change the value of a database field, which is what your statement looks like it is trying to do.
    You need to have the formula return a result like this:

    if {PART_BATCHES.BATCH_DATE} <= currentdate
    then "exp"
    else totext({BIN_LOCATION_DETAILS.QTY_IN_BIN},0)

    Make sure that the formula syntax is set to "Crystal Syntax".  It will be in a drop down in the formula editor.

    Author Comment

    bdreed35, Thanks! I tried your syntax, and your suggestion give the error formula result must be boolean... ???
    LVL 28

    Accepted Solution

    Where are you putting this formula?  You need to go the Field Explorer, right click on "Formula Fields", and choose New.  Give it a name and then paste the logic I gave you there.
    If you still get the error after that, you will need to tell me what data types Batch Date and Qty In Bin are.

    Author Comment

    Excellent! I was trying to put the formula in as a common suppress varible. (Format Field).
    When I put the code within the field explorer it worked - Thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
    Read about achieving the basic levels of HRIS security in the workplace.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now