null value in a field data type as date 
Author Message
 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!!!



Wed, 26 Apr 2000 03:00:00 GMT  
 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!!!




Mon, 01 May 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. NULL VALUES IN DATE FIELD - TYPE MISMATCH ERROR

2. Null date values in Date/Time fields in Access DB

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

4. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

5. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

6. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

7. Populating Null value in SQL Date/Time field

8. How to give Date fields null values?

9. Allowing a date field to be null value

10. Re.allowing a date field to take null value

11. date field and null values

12. Update a DATE-field to a NULL-value

 

 
Powered by phpBB® Forum Software