
null value in a field data type as date
You cant write an empty string to a numeric field (including a date
field).
On the validation event of a data control, I use the following code to
deal with deleting a number or date:
'CHECK FOR DELETED DATES OR NUMBERS
'This check is required because vb5 doesn't
' handle the deletion of date or number fields
' bound by a data control (it generates an error)
SpecialSave = False declared at the form or project level
'Tag any date fields which have been changed to blank
For x = 0 To Me.txt_CertificateDate().UBound
If Me.txt_CertificateDate(x).DataChanged And _
Len(Me.txt_CertificateDate(x)) = 0 Then
Me.txt_CertificateDate(x).DataChanged = False
Me.txt_CertificateDate(x).Tag = "Update" & _
Me.txt_CertificateDate(x).Tag
SpecialSave = True
End If
Next
If SpecialSave Then
Dim varBookMark As Variant
'Update record
If Me.dat_Certificates.Recordset.EditMode <> 0 Then
varBookMark = Me.dat_Certificates.Recordset.Bookmark
Me.dat_Certificates.UpdateRecord
End If
'Make sure we are on the right record
I do this because Im a paranoid programmer.
Me.dat_Certificates.Recordset.Bookmark = varBookMark
'Edit record
Me.dat_Certificates.Recordset.Edit
'Set tagged date field(s) to null
For x = 0 To Me.txt_CertificateDate().UBound
If Left$(Me.txt_CertificateDate(x).Tag, 6) = _
"Update" Then
Me.dat_Certificates.Recordset.Fields( _
Me.txt_CertificateDate(x).DataField) = Null
If Len(Me.txt_CertificateDate(x)) > 6 Then
Me.txt_CertificateDate(x).Tag = _
Mid$(Me.txt_CertificateDate(x), 7)
Else
Me.txt_CertificateDate(x).Tag = ""
End If
End If
Next
Me.dat_Certificates.UpdateRecord
End If 'SpecialSave
SpecialSave = False
You should get the idea from the above code. If you have existing tag
values, it isnt hard to change the code to leave these tag values
untouched.
Quote:
-----Original Message-----
Posted At: Saturday, November 08, 1997 4:13 AM
Posted To: database
Conversation: null value in a field data type as date
Subject: null value in a field data type as date
Hi everyboby,
I'm a new user of computer, especially VB5,and I've got a big
problem.Here
it is:
In a text box control associated to a data type as date field
from an
Access 97 table, I can't give it an Empty value ("").
I mean it takes it, but when I do the .UpdateRecord it gives me
this
run-time error: '524':Data Type Conversion Error.
Who will be so kind to help me, please?
Thank you in advance!!!