Results 1 to 3 of 3

Thread: Crystal Report 10 Formula not working?

Hybrid View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Crystal Report 10 Formula not working?

    I'm using CR 10. I have a report that has a simple formula that formats a customers address information. The address isn't showing up on the report. The problem is that all the records have data in them except for some of the Address2 and Address3 data fields. I've tried dropping the individual Contact fields onto the report and it works fine. Here is the formula below.

    Code:
    Dim strformula as String
    
    if {AR_Customer.CustomerName} <> "" then 
        strformula = {AR_Customer.CustomerName} & chr(13) + chr(10)
    end if
    
    if {AR_Customer.AddressLine1} <> "" then 
        strformula = strformula & {AR_Customer.AddressLine1} & chr(13) + chr(10)
    end if
    
    if {AR_Customer.AddressLine2} <> "" then 
        strformula = strformula & {AR_Customer.AddressLine2} & chr(13) + chr(10)
    end if
    
    if {AR_Customer.AddressLine3} <> "" then 
        strformula = strformula & {AR_Customer.AddressLine3} & chr(13) + chr(10)
    end if
    
    if {AR_Customer.City} <> "" then
        strformula = strformula & {AR_Customer.City} & ", " 
    end if
    
    if {AR_Customer.State} <> "" then
        strformula = strformula & {AR_Customer.State} & "  "
    end if
    
    if {AR_Customer.ZipCode} <> "" then
        strformula = strformula & {AR_Customer.ZipCode}
    end if
    
    formula = strformula
    What am I doing wrong. I'm using Basic Syntax for all my formulas.

    Thanks,
    Last edited by blakemckenna; May 1st, 2009 at 10:34 AM.
    Blake

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Crystal Report 10 Formula not working?

    If any one of the database fields contains a Null then the result of the formula will be Null.

    Either use the IsNull function on each line that could possibly contain a Null

    Code:
    if Not IsNull({AR_Customer.AddressLine2}) And {AR_Customer.AddressLine2} <> "" then 
        strformula = strformula & {AR_Customer.AddressLine2} & chr(13) + chr(10)
    end if
    Or have CR convert ALL Nulls to a default value by setting the option Convert Null Field Value to Default (File\Report Options menu). Note the Perform Grouping On Server option must be off in order for this option to be enabled.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Crystal Report 10 Formula not working?

    Bruce,

    That worked!!! I just saw something that I didn't do and that was change the "or" to "and" for a compound statement. After doing that, it worked fine!!!

    Thanks for your help!
    Blake

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