This topic is locked

How can we allow null values in number type field?

5/5/2004 2:16:27 PM
ASPRunnerPro General questions
Pete M author

Hi Sergey,
I have a field which I only want a number entered, and have set the 'edit as' to 'number'. It is not set as a required field.
The problem is that a null entry is tested as a number, and the record cannot be saved. entering '0' as a default causes problems because the numbers go into minus values, so '0' might be a real entry value.
How can I allow number type fields to be saved as a null value?
Thanks
Pete

Sergey Kornilov admin 5/6/2004

Pete,
here is what you can do. In ..._edit.asp file find the following code snippet (lines 114-116):

' Date or GUID field with no value

if Request.Form(Request.Form("FieldName")(i))="" and ( nType=72 or nType=133 or nType=134 or nType=135 ) then

strValue = "NULL"   


You can alter IF condition to check for numeric fields ( nType=3 ) or for any specific field name.
Let me know if you need more help.