Print Page | Close Window

A Number is required here - error message

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20867
Printed Date: 28 Apr 2024 at 10:17pm


Topic: A Number is required here - error message
Posted By: sallyjenkins
Subject: A Number is required here - error message
Date Posted: 07 Jul 2014 at 11:14am

I am using Crystal Reports 11.5 and Crystal Reports syntax.  I am reading from a SQL DB

 

Here are the SQL Field types.

{AckParagraphs.AckParagraphBlurb} is a VarChar(Max)

{AckParagraphs.AckParagraphNum} is a nchar(5)

 

ParaNum is a Global NumberVar set to 999 in the group header.

 

The purpose of this formula is to print each detail line until a blank field is reached.  When the record with the blank field is read I want the variable set to the paragraph number.  This variable will be used in other formulas when printing records.

This formula is throwing and error on the 2nd 'If' "A number is required here.

If isNull({AckParagraphs.AckParagraphBlurb}) THEN

    ParaNum := ToNumber({AckParagraphs.AckParagraphNum}) 

Else If ParaNum = 999 THEN

    {AckParagraphs.AckParagraphBlurb}


I'm at a total loss. 



-------------
SAJ



Replies:
Posted By: DBlank
Date Posted: 07 Jul 2014 at 12:04pm

all possible results from a formula must return the sama data type

You don't have to display your formula field to use it in another formula


Posted By: sallyjenkins
Date Posted: 07 Jul 2014 at 12:12pm
If I understand correctly, this is blowing up because I am displaying the
{AckParagraphs.AckParagraphBlurb} - correct?

If that is so, then perhaps I should not set ParaNum
to a Numbervar.  The ParaNum is then set to {AckParagraphs.AckParagraphNum} (a string value, not changed to a number value).

am I getting warm?


-------------
SAJ


Posted By: DBlank
Date Posted: 08 Jul 2014 at 3:52am
yes. they both need to be a string or numeric and clearly the numeric won't work for the blurb.
However, not knowing what your end game is here i cant really tell you how I would approach it.
 
This will give you the paragraph number for anything where the the blurb is null and a 999 for the non NULL rows... 
if isNull({AckParagraphs.AckParagraphBlurb}) THEN 999 ELSE ToNumber({AckParagraphs.AckParagraphNum}) 
 
However, I am concerned that you are trying to do some sort of linking on the reult of this formula. All your row level data has already been set via the table links by the time this formula is executed.


Posted By: sallyjenkins
Date Posted: 08 Jul 2014 at 4:35am
Many thanks for elaborating.  I am not going to be linking on ParaNum, but will be evaluating later.
I will give this a go later today.


-------------
SAJ



Print Page | Close Window