Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

isnull function in Crystal Custom Functions

Status
Not open for further replies.

Matt27

MIS
Jun 2, 2004
59
GB
I have a custom function in Crystal XI which I've copied from Visual Basic. I've selected the basic syntax in Crystal. It works fine apart from one part where it's coming up with an error message - it says the isnull function cannot be used within a custom function. Does anyone know a way round this (i.e. another function perhaps that I could use)?
 
The function is supposed to convert a date. The line I'm having a problem with says "if isnull(Req_Date) Then ...."

At the top of the custom function I have the following line:- "Function ConvertDate(Req_Date As Date) As String
 
I don't know Visual Basic. But as a work-round, you could test for a null date using Crystal, set a Y or N result and then test for it in your 'custom function'.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
The custom function is in Crystal and I will be adding it to the repository once it works. So it isn't going to be a custom function specific to one report bu in the repository and therefore available for any reports I produce. To do the test you mention I would need to create a formula in Crystal - would this not be specific to the report?
 
convert a date" is not a meaningful response to "Post what the function is supposed to do."

Perhaps something like this would work:

IF Length(Req_Date) > 0 THEN ...

- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Hi,
If I recall correctly custom functions do not have access to other Crystal functions since they are not in the same scope..
A user-defined function is probably 'unaware' of Crystal-defined ones.
This is a different situation than using multiple, combined functions in a formula; the formula has access to the entire Crystal environment, so all the functions, etc. are available to use.

You may have to write your own test for NULL within your function.




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Another work around could be to set you report options to convert Null data to default.

In the case of Dates it should return Date(0,0,0)

so instead of

if isnull(Req_Date) Then

use

If (Req_Date) = Date(0,0,0) then ...

However, if you are testing for Nulls in other data types you will have to make similar changes.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top