I have a Year_table in my DB that has YrID auto as primary and then I did YR and that is 2013, 2014 right now and I choose YYYY in format. I used to have it as numeric but it would not work with some coding because my coding for a filter is limited to and I do not know how to throw another piece in to this for numeric. The problem is, I changed it to date so the below code would work and it does and everything appears fine, however when I test to publish to my SharePoint I get that the Year table format is not supported by the host. Is this because I did format YYYY and it has to be one of the dates that appears in the list? I would prefer not to go in and recode all my forms for datepart so only the YYYY shows up. Is there a way around this? Perhaps adding a numeric function to my code below?
Code:
Public Function GetProperType(varitem As Variant, fieldType As String) As Variant
If fieldType = "Text" Then
GetProperType = sqlTxt(varitem)
ElseIf fieldType = "Date" Then
GetProperType = SQLDate(varitem)
Else
GetProperType = varitem
End If
End Function
Public Function sqlTxt(varitem As Variant) As Variant
If Not IsNull(varitem) Then
varitem = Replace(varitem, "'", "''")
sqlTxt = "'" & varitem & "'"
End If
End Function
Function SQLDate(varDate As Variant) As Variant
If IsDate(varDate) Then
If DateValue(varDate) = varDate Then
SQLDate = Format$(varDate, "\#mm\/dd\/yyyy\#")
Else
SQLDate = Format$(varDate, "\#mm\/dd\/yyyy hh\:nn\:ss\#")
End If
End If
End Function