 |
| 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
|
|
|
|

October 14th, 2003, 05:37 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
formula
I need to do a formula field "@DateDoc".
First, I will check the field (Date_Doc), If it's empty, then the @DateDoc will display "-", Else if the field contain value, then I will display the Value of the field.
------------------------------------------------------
If {WOS.Date_Doc} = "" Then
{@DateDoc} = "-"
Else
{@DateDoc} = {WOS.Date_Doc}
End If
-------------------------------------------------------
But there's an error occurred :
"A statement expected!"
Please assist.
Thanks.
|
|

October 14th, 2003, 05:46 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Winnie,
If you are using Basic Syntax you can do this
If {WOS.Date_Doc} = "" Then
formula = "-"
Else
formula = {WOS.Date_Doc}
End If
And if you're using Crystal Syntax simply omit the word "formula"
and "end if"
If {WOS.Date_Doc} = "" Then
"-"
Else
{WOS.Date_Doc}
-Dhodie
|
|

October 14th, 2003, 08:32 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks.
basic syntax:
I tried both codes :-
If {WOS.Date_Doc} = "" Then
formula = "-"
Else
formula = {WOS.Date_Doc}
End If
cyristal syntax:
If {WOS.Date_Doc} = "" Then
"-"
Else
{WOS.Date_Doc}
ERROR :
-------
"A Date-Time is required here"
|
|

October 14th, 2003, 09:32 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi winnie!
Sorry i didnt noticed that you are using Date Field
In your code you are trying to compare a date field to an empty string that's why you have encountered "A Date-Time is required here" error. If you're checking if {WOS.Date_Doc} is null try changing your code to this
crystal syntax
If IsNull( {WOS.Date_Doc}) Then
"-"
Else
Cstr({WOS.Date_Doc})
Notice that i converted {WOS.Date_Doc} to string by using the Cstr function to make the returning value same in data type.
-Dhodie
|
|

October 14th, 2003, 10:19 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks a lot! :)
Will ask u again if there's any problem
Have a wonderful day :)
|
|

October 14th, 2003, 11:57 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Dhodie,
Can I control the fdatabase field and if the value is null or "" then it's = "-" instead of using formula field?
How can I control it?
there's a few options :-
-Suppress
-keep object
-close border on page break
-can grow
suppress if duplicated
-Winnie
|
|

October 15th, 2003, 12:18 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If you are connecting to SQL Server you can have the null
values replace by any values that you choose. In this case "-"
ex.
ISNULL(check_expression, replacement_value)
If you have a query like "Select {WOS.Date_Doc} from SampleTable"
you can change it to "Select IsNull({WOS.Date_Doc},'-') from SampleTable". This will replace all null values of your query to "-".
-Dhodie
|
|

October 15th, 2003, 04:09 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If you are connecting to SQL Server you can have the null
values replace by any values that you choose. In this case "-"
ex.
ISNULL(check_expression, replacement_value)
If you have a query like "Select {WOS.Date_Doc} from SampleTable"
you can change it to "Select IsNull({WOS.Date_Doc},'-') from SampleTable". This will replace all null values of your query to "-".
-Dhodie
----------------
Thanks.
I'm using ado.net to connect. the "Select IsNull({WOS.Date_Doc},'-')"
is used at the field database in the crystal report? or in the sql query?
|
|

October 15th, 2003, 04:28 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Do it in SQL Query
-Dhodie
|
|

October 15th, 2003, 05:27 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks.
for the formula :
If IsNull({WOS.Date_Sum}) Then
"-"
Else
Cstr({WOS.Date_Sum})
Result value = eg. 18/08/2001 00:00:00
How can I convert it to value eg. 18/08/2001 or 18-Aug-2001 ??
Thanks.
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Help with formula |
Juan0214 |
Access |
4 |
August 1st, 2008 07:25 AM |
| Formula |
scandalous |
Access VBA |
11 |
February 27th, 2007 09:49 AM |
| formula |
sinha |
Crystal Reports |
1 |
October 26th, 2005 12:53 PM |
| Help with a formula |
Corey |
Access |
2 |
October 20th, 2005 10:48 AM |
| Formula |
Ned |
Pro VB 6 |
2 |
September 10th, 2003 10:26 AM |
|
 |