Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Move null dates from oracle database to vb6 form

Move null dates from oracle database to vb6 form

Move null dates from oracle database to vb6 form

A form that has worked for years is not getting a datatype mismatch (runtime error 13) and I don't understand why or how to fix it.
Basically, I'm retrieving a recordset from an oracle database and placing the values in textboxes.  For date fields, I now get the error if the database field is null.  Can someone tell me what needs to be changed to allow text boxes to accept null values?


 txtLine1.Text =
IIf(IsNull(rs("WatermeterDate")), Null, Format(rs("WATERMETERDATE"), "mm/DD/yy"))
 txtline2.Text =
IIf(IsNull(rs("WaterLeakageDate")), "", Format(rs("WATERLeakageDATE"), "mm/DD/yy"))
The 2nd date is how it's always been and I just tried to substitute the Null value but get same error.

RE: Move null dates from oracle database to vb6 form

It's been a while since I've worked with VB6, but the following is a .Net version of the NotNull function I used to use to handle that exact problem. Just convert this back to VB6 (don't have it installed anymore or I'd post it):


'Example of usage:  txtInvNum.Text = NotNull(InqDt.Rows(0).Item("InvNum"), "")

    Public Function NotNull(ByVal dbArg As Object, Optional ByVal DefaultVal As String = "") As String
        'This is used to clean up any NULLS coming OUT of the database.
        '   You can set a default value if the DB Argument is NULL.
        '   Default return value is "".
        NotNull = ""
            If dbArg Is Nothing Then
                NotNull = DefaultVal
                If String.IsNullOrEmpty(dbArg.ToString) = True Then
                    NotNull = DefaultVal
                    NotNull = dbArg.ToString
                End If
            End If
        Catch Ex As Exception
            NotNull = DefaultVal
        End Try
    End Function

"Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month." --Wernher von Braun

RE: Move null dates from oracle database to vb6 form

finally determined that it wasn't my code to load the combo boxes but invalid dates (1801, 0010) being stored as the year.  When I did the debug, these showed up as nulls.  I forced the dates to be displayed as 4 digit years to avoid this problem. Thanks for your help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close