|
-
Mar 10th, 2003, 05:12 AM
#1
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
-
Mar 10th, 2003, 11:45 AM
#2
Addicted Member
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.
-
Mar 11th, 2003, 12:04 AM
#3
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
-
Mar 11th, 2003, 06:26 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|