|
-
May 1st, 2009, 10:21 AM
#1
Thread Starter
PowerPoster
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
-
May 1st, 2009, 01:04 PM
#2
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.
-
May 1st, 2009, 03:44 PM
#3
Thread Starter
PowerPoster
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|