Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Empty 'Date' field (2003)

    Following instructions in another post from HansV, I created the following module:
    - - - - - - - - - - -
    Option Compare Database
    Option Explicit

    Public placeHolderDOB As Date

    Public Function GetPlaceHolderDOB() As Date
    GetPlaceHolderDOB = placeHolderDOB
    End Function
    - - - - - - - - - - -
    Then, I extract the value for "placeHolderDOB" from the fourth column of a ListBox. The problem is that some of the rows do not have a date value (they are Null). The question is, how can a construct a statement that reads the value of that ListBox's fourth column and, if it finds a Null value, sets "placeHolderDOB" to Null but, if else, sets "placeHolderDOB" to that value. I've tried several combinations and some searches here and there but can't find the solution I'm looking for. Thanks for any guidance!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Empty 'Date' field (2003)

    You'll have to change the data type of placeHolderDOB and of GetPlaceHolderDOB to Variant, for a Date variable cannot contain a null value.

    Public placeHolderDOB As Variant

    Public Function GetPlaceHolderDOB() As Variant
    GetPlaceHolderDOB = placeHolderDOB
    End Function

    Use code like this, substituting the correct name:

    If Nz(Me.Listboxname.Column(3),"") = "" Then
    placeHolderDOB = Null
    Else
    placeHolderDOB = Me.Listboxname.Column(3)
    End If

    Columns are counted starting at 0, so the fourth column has index 3.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Empty 'Date' field (2003)

    Adjustments worked. Had no idea that "Nz" existed. Thanks,Hans!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •