# Thread: FORCE NUMERIC NOT EQUAL "BLANK"

1. ## FORCE NUMERIC NOT EQUAL "BLANK"

I HAVE A SITUATION WHERE I NEED TO ENTER NUMBER DIRECTLY INTO A FIELD ON A FORM. THIS WORKS VERY WELL AND SINCE THERE ARE MORE THAN 10 FIELD THAT THE USER NEED TO ENTER QTY VALUE///

THE FIELD ITSELF IS A "NUMERIC"

AFTER CAREFUL INVESTIGATION ON APPLICATION CRASHES//

I DISCOVERED THAT WHEN SOMEONE ENTER A BLANK INTO THE FIELD INTENTIONALLY ? THE APPLICATION WILL EVENTUALLY CRASH ALONG WITH OTHER OPERATION COMBINATIONS OF KEY STROKES.

I OPT THE IDEA TO PUT CODE WITHIN THE FIELD_RULE OF THE TABLE'S FIELDRULE'S EVENTS

CANWRITEFIELD....

IF A_FIELD_VALUE=""
A_FIELD_VALUE=0
END IF

ETC....

THAT DOESNOT SEEMS TO MAKE ANY DIFFERENCE
WHEN I ENTER BLANK INTO THAT PARTICULAR NUMERIC FIELD
IT STILL REMAIN "BLANK"

THANKS
KEN TJIA

2. ## RE: FORCE NUMERIC NOT EQUAL

Ken,

Not sure I can be of any help, but check out the MATH_NAN costant in Xbasic.

Here is something Cian Chambliss posted a while ago, that may get you started:

Msg ID: 34378
Subject:
RE: Numeric 0 vs. numeric blank
Author: cian chambliss
Date: 01-29-2001 09:27
File: Unitialized numeric fields in A5 contain the value of non-a-number
(represented by the constant MATH_NAN) -- here is an example done in
the a5v4 script editor interactive window:

x = 0
? isblank("var->x")
= .F.

x = math_nan

? isblank("var->x")
= .T.

3. ## RE: FORCE NUMERIC NOT EQUAL

IF FIELD="" IS NULL

TRY IF FIELD=" " WITH A BLANK BETWEEN QUOTES

BOB

4. ## RE: FORCE NUMERIC NOT EQUAL

Hi Ken,

Could you somehow force a zero into the field if it is blank, perhaps testing the text property of the control on the form. I believe even controls bound to numeric fields have a text property: the characters in the control as opposed to the value in the field.

On departing the field if controlname.text="" set it to "0".

Bill

5. ## RE: FORCE NUMERIC NOT EQUAL

Have you tried to give the field a default value of 0.00. A nul value has a character value and therefore cannot be calculated with numbers.

Keith Hubert
London.

6. ## RE: FORCE NUMERIC NOT EQUAL

You can also force a zero by using the OnDepart action event for the field on the form. This will change an entered space to a numeric zero.

VMODE=YOUR_FORM_NAME.MODE_GET() 'get entry mode-script will not fire in view mode
SELECT
CASE VMODE="ENTER".OR.VMODE="CHANGE"
TBL=TABLE.CURRENT()
IF TBL.YOUR_FIELD_NAME=0
TBL.YOUR_FIELD_NAME=0
YOUR_FIELD_NAME.REFRESH()
END
END IF
END SELECT

Mick

7. ## RE: FORCE NUMERIC NOT EQUAL

try

if a_field_value="" then
a_field_value="0"
end if

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•