PRB: "Data Type Conversion Error" When Using a Data ControlLast reviewed: September 25, 1997Article ID: Q172101 |
The information in this article applies to:
SYMPTOMSDeleting the data from a text box bound to certain data types, such as an integer or date, causes Error 3421:
"Data Type Conversion Error."NOTE: If you are using a dbGrid, it's Error Method will produce Error 16389.
CAUSEThis is designed behavior of DAO. The data control is sending a NULL string to DAO and DAO attempts to coerce it to a number and fails. This is not a problem with the Data Control: The same behavior can be observed without the use of a Data Control, using only code. For example:
Set db = OpenDatabase("nwind.mdb", False, False) Set rs = db.OpenRecordset("select shipvia from orders", dbOpenDynaset) rs.Edit rs(0) = "" RESOLUTIONUse the following code in the Data Controls Validate method to allow the edit to occur as expected by user:
Private Sub Data1_Validate(Action As Integer, Save As Integer) If Text1.DataChanged Then Text1.DataChanged = False 'So this data is not saved Data1.UpdateRecord ' This saves the data that ' may have changed in the other controls ' Now clear the numeric field Data1.Recordset.Edit Data1.Recordset![Year Born] = Null Data1.Recordset.Update End If End Sub STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional query words: empty
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |