Results 1 to 2 of 2
  1. #1
    cuddles is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    98

    Real Problem with Year_Table

    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

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Format function results in a string value, not a true date or number. Setting format property in table does not change the original data.

    So in the Year_table, not saving 2013, 2014? You save a full date and then apply format with field property or with Format function?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update the Customer No in real time
    By gstylianou in forum Access
    Replies: 6
    Last Post: 06-08-2014, 09:38 AM
  2. Real Time Incremental Back Up
    By GrnMtn7 in forum Access
    Replies: 1
    Last Post: 10-15-2011, 05:29 PM
  3. Translating Windows name into Real Name
    By runthis457 in forum Forms
    Replies: 13
    Last Post: 02-14-2011, 06:20 PM
  4. real time clock
    By krai in forum Access
    Replies: 1
    Last Post: 05-13-2010, 05:11 AM
  5. newbie-real NOVICE
    By SHCC in forum Database Design
    Replies: 1
    Last Post: 02-09-2010, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums