VBA functions to deal with missing values in CLng CDbl and CDate


Public Function fnCDate(sInput As String) As Date
On Error GoTo Exit_Function
 fnCDate = #1/1/1900#
 If Len(sInput) = 0 Then
  GoTo Exit_Function
 Else
  fnCDate = CDate(Mid(sInput, 1, 19))
 End If
Exit_Function:
End Function

Public Function fnCLng(sInput As String) As Long
On Error GoTo Exit_Function
 fnCLng = 0
 If Len(sInput) = 0 Then
  GoTo Exit_Function
 Else
  fnCLng = CLng(sInput)
 End If
Exit_Function:
End Function

Public Function fnCDbl(sInput As String) As Double
On Error GoTo Exit_Function
 fnCDbl = 0#
 If Len(sInput) = 0 Then
  GoTo Exit_Function
 Else
  fnCDbl = CDbl(sInput)
 End If
Exit_Function:
End Function

Public Function fnTableExists(sTablename As String) As Boolean
 On Error GoTo Exit_Function
 fnTableExists = False
 If IsObject(CurrentDb.TableDefs(sTablename)) Then fnTableExists = True
Exit_Function:
End Function