Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2005, 04:26 AM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crystal Reports Use formula

Hi,

    By using use formula method in Crystal Report,I want to change "0" (numberic value) to "-" at run time, If it is not 0, I want to display the same value in the field.I had tried by using following code.

 if{tb_test.n2}=0 then
 "-"
 else
{tb_test.n2} // Error: Use string value, But the field is numberic.

        If I remove the "Else" part also it is not showing "-", Please help me in this regard.

 Best Regards,

   Sayeed.

 
Old February 5th, 2005, 09:11 PM
FD FD is offline
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Sayeed

The problem is due to the mix of numeric and text. A solution I often use requires 2 formula fields as follows:

[u]field1</u>
if {tb_test.n2}=0 then '-' else
totext({tb_test.n2})

[u]field2</u>
if {tb_test.n2}<> 0 then tonumber({@else})

Using the 'suppress' option in format field ;

[u]field1</u>
{tb_test.n2} <> 0 // suppress field1 if true

[u]field2</u>
{tb_test.n2} = 0 //suppress field2 if true

By laying one field on top of the other you will have the represenative information on your report.

Good luck
FD






 
Old February 7th, 2005, 01:01 PM
Authorized User
 
Join Date: Dec 2004
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can try this,
if{tb_test.n2}=0 then
 "-"
 else
totext({tb_test.n2},2,'')

usually when u use the formula the result fld muat be of same datatype.
here i assumed that u want 2 decimal places no thousand seperator.
Thanks,
Kavitha.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in formula in Crystal Report Prakash001 Crystal Reports 10 December 5th, 2007 04:12 AM
crystal report formula suresh.cgmohan VB How-To 0 November 2nd, 2006 06:10 AM
Scroll dataset using crystal formula saf01 Crystal Reports 0 February 22nd, 2006 02:12 PM
needing help for formula editor in crystal report anilkumar Crystal Reports 1 January 7th, 2004 04:13 PM
Pass String webpage to Crystal Report (formula) winnie1778 Crystal Reports 0 October 18th, 2003 01:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.