[AccessD] All-In-One Date format Function:

Gustav Brock Gustav at cactus.dk
Wed Oct 21 15:43:55 CDT 2009


Hi Robert

Here's a method as a starter:

Public Function DateParse(ByVal strInput As String) As Date

  Dim strDate As String
  Dim datDate As Date
  
  If IsDate(strInput) Then
    strDate = strInput
  End If
  
  If Len(strDate) = 0 Then
    strDate = Format(strInput, "00/00/00")
    If Not IsDate(strDate) Then
      strDate = vbNullString
    End If
  End If
  If Len(strDate) = 0 Then
    strDate = Format(strInput, "00/00")
    If Not IsDate(strDate) Then
      strDate = vbNullString
    End If
  End If
  If Len(strDate) = 0 Then
    strDate = Format(strInput, "0/0")
    If Not IsDate(strDate) Then
      strDate = vbNullString
    End If
  End If
  
  If Len(strDate) = 0 Then
    datDate = Date
  Else
    datDate = CDate(strDate)
  End If
  
  DateParse = datDate
  
End Function

/gustav

>>> robert at servicexp.com 21-10-2009 21:18 >>>
Thanks for the reply Lambert,
  The great thing is, I don't have to worry about in what order the date is
entered. Currently all dates are entered in "09/21/09" format. The request
is "we would like to minimum keystrokes (see below) and have the users enter
the date as 0909 for CC and 092109 for all other date fields.  (I want to
parse the date and format it correctly to protect against 909 or 32109.. etc
entries... 

 The owner want the fastest possible key entry to his employees. Reaching
for a mouse is not an option here..;-)

Even if I did have to worry about the date order, I should be able to format
the end entry to the system formatting very easily right?, it's the parsing
that's the challenge.. :-)

Thanks Again

WBR
Robert






More information about the AccessD mailing list