Null Database Fields from Bound Texboxes

Null Database Fields from Bound Texboxes

Post by Clive Grange » Thu, 11 Sep 1997 04:00:00



I am updating an Access7 database table date field using a bound textbox
via a data control in VB5.  In the validation event I check to see if it is
a valid date or blank and stop the update if the field is invalid.  

If the field is modified in any way and then all the characters deleted the
value in the textbox becomes a zero length string ("").

A zero length string does not seem to be acceptable to the database and I
cannot set the text1.text to NULL (runtime error 94-Invalid use of Null).  

How do I pass a NULL value to the database once the textbox.text has been
modified?
Thanks,
Clive

 
 
 

Null Database Fields from Bound Texboxes

Post by Jim Fergus » Fri, 12 Sep 1997 04:00:00


Quote:>A zero length string does not seem to be acceptable to the database

It's not, unless you set the .AllowZeroLength property of the field.

Quote:>and I
>cannot set the text1.text to NULL (runtime error 94-Invalid use of Null).  

You can't set the TEXT box to null. You have to set the corresponding
field in the data control's recordset to null:

data1.recordset.edit
data1.recordset.fields!yourfield = null
data1.recordset.update

-- Jim Ferguson, FMS
   http://www.fmsinc.com

 
 
 

1. Null Database Fields from Bound Textboxes

I am updating an Access7 database table date field using a bound textbox
via a data control in VB5.  In the validation event I check to see if it is
a valid date or blank and stop the update if the field is invalid.  

If the field is modified in any way and then all the characters deleted the
value in the textbox becomes a zero length string ("").

A zero length string does not seem to be acceptable to the database and I
cannot set the text1.text to NULL (runtime error 94-Invalid use of Null).  

How do I pass a NULL value to the database once the textbox.text has been
modified?
Thanks,
Clive

2. Windows 2000 native-mode domain + SQL Server 7.0

3. Using date fields in texboxes.

4. Decode OR CONDITIONAL IF

5. ado data binding (with bindtorecordset) and null fields = problems for me

6. Kill Process in Stored Procedure

7. Setting bound numerical/date ADO fields to Null

8. Inventory DB

9. Binding NULL fields

10. Error 3426 with Null Bound Combo Box Field.

11. Assigning Null Values to data bound fields using remote data control

12. Bound controls, setting field to Null ?

13. data field + NULL field = NULL???