Results 1 to 4 of 4

Thread: Crystal Report Formula Editor.

  1. #1

    Thread Starter
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Question Crystal Report Formula Editor.

    Hi,
    I have a nullable datefield being retrieved from a sqlserver table.
    I wish to put in a formula which checks if the field is null and if null, print "Not Authorised" in the report.

    How do I write a formula?

    Another question on Crystal Reports...
    How do i have multiple ifs in one single formula?

    Cheers!
    Abhijit
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  2. #2
    Addicted Member
    Join Date
    Jan 2001
    Location
    MPLS
    Posts
    187
    If your creating the formula in the designer, then click formula in the field explorer, then click new. Give the new formula a name. Then create your fomula like...

    if isnull({TABLE.FIELD) then "Not Authorised"
    else {TABLE.FIELD}

    As for multiple if's, thats ok. Just use standard vb if-then-else structure in your formulas. Check the help files in the designer and it will explain the syntax of the formula editor.

  3. #3

    Thread Starter
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Unhappy Did not work

    Hi Ducky,
    I tried doing it.
    Code:
    if isnull({UserDefTable.CreatedDateTime}) then "UnAuthorised"
    However the error message that I get is
    The formula result must be a boolean.
    So I changed it to this.
    Code:
    if isnull({UserDefTable.CreatedDateTime}) then "UnAuthorised"
    else {UserDefTable.CreatedDateTime}
    This caused another error "A String is required here".
    So I further changed my code to
    Code:
    if isnull({UserDefTable.CreatedDateTime}) 
        then "UnAuthorised Access"
    else "Allowed To DO It"
    This is causing the same error as before. I am using SQL Server 2000. Can I use something to convert this datevalue to a string in the formula editor?

    Help,
    Abhijit
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    A Formula cannot return different datatypes.

    Use the ToText or CStr functions to convert dates, numbers etc to strings.

    if isnull({UserDefTable.CreatedDateTime}) then "UnAuthorised"
    else ToText({UserDefTable.CreatedDateTime}, "dd-MMMM-yyyy" )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width