Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

A Number is required here - error in Formula

Posted on 2004-08-11
3
Medium Priority
?
2,267 Views
Last Modified: 2010-08-05
Hi All,
Sorry about the basic question but I am new to Crystal


I have a lot of Null entries and I wish to display a string where a entry is null.  I am tryiang the Formula below but it keeps coming back with the error message " a number is required here"

stringVar Message := "Patient to seen or time seen not recorded";

If not Isnull({@Seen Date-Time})
then
(
DateDiff ("n",{@Referral Date-Time} ,{@Seen Date-Time} )
)
else
Message;

Does anyone have any idea I might do this??

Thanks a million,
Nicky
0
Comment
Question by:NickyNin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Expert Comment

by:GJParker
ID: 11774666
Your problem here is that crystal functions will only allow you to return one data type.

In your formula if the field is null then the calculation returns a number where as if the field is null you are attempting to return  a string.

One way around this would be to convert the Datediff calculation to a string i.e.

stringVar Message := "Patient to seen or time seen not recorded";

If not Isnull({@Seen Date-Time})
then
(
ToText(DateDiff ("n",{@Referral Date-Time} ,{@Seen Date-Time} ))
)
else
Message;

Gary
0
 

Author Comment

by:NickyNin
ID: 11781826
Thanks for your reply!!

Unfortunately I need the result to be a number as I then use this number in a calculation.  It tells me that the "a number is required here"

I have tried to convert it back into a number ( see Below) but I get the error message " The string is non numeric"


if IsNull ({@DateDiff})
then 0
else if ToNumber({@DateDiff}) < 10
then -6
else if ToNumber({@DateDiff}) in 10 to 60
then -5
else if ToNumber({@DateDiff}) in 60 to 120
then -4
else if ToNumber({@DateDiff}) in 120 to 240
then -3
else if ToNumber({@DateDiff}) > 240
then -2
else 0
0
 
LVL 19

Accepted Solution

by:
GJParker earned 500 total points
ID: 11781876
Try This

If IsNumeric({@DateDiff})) Then
   if ToNumber({@DateDiff}) < 10 then -6
   else if ToNumber({@DateDiff}) in 10 to 60 then -5
   else if ToNumber({@DateDiff}) in 60 to 120 then -4
   else if ToNumber({@DateDiff}) in 120 to 240 then -3
   else if ToNumber({@DateDiff}) > 240 then -2
Else
   0

Gary

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question