Results 1 to 8 of 8
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    property date

    All; Using Access 2010. I have the following code to add the current date to the current table when a new table with the same name is imported. The code is fine except now I need the date the current table was created instead the current date added. Ex. Current table name tblCur when the new tblCur is imported; the current tbl becomes tblCur05112015 but it was created on 05052015. How can I get the date the table was created which is the table property date?



    Code:
    'Open backend and add date to tblCur to allow for import of current data
    Dim dbBackend As DAO.Database
    Dim strBackendDatabase As String
    Dim tdf As DAO.TableDef
      strBackendDatabase = "C:\ProjectsaccdbCurFiles.accdb"
      Set dbBackend = OpenDatabase(strBackendDatabase)
       
        For Each tdf In dbBackend.TableDefs
        If tdf.Name = "tblCur" & Format(Date, "yyyymmdd") Then Exit For
        Next tdf
        If tdf Is Nothing Then
        dbBackend.TableDefs("tblCur").Name = " tblCur " & Format(Date, "yyyymmdd")
         dbBackend.Close
         Else
        ' The archive table already exists: Take action (Rename, Delete, Warns...)
    End If

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    I have a field: IMPORTDATE, default = NOW()

    It shows when the date/time the data was imported.
    This uses ZERO CODE.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    In your loop, something like tdf.datecreated should give you the information you need, without having to know what the actual table name is.

  4. #4
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    So; Do I replace

    Code:
    If tdf Is Nothing Then
        dbBackend.TableDefs("tblCur").Name = " tblCur " & Format(Date, "yyyymmdd")
         dbBackend.Close
         Else
    with
    Code:
    If tdf Is Nothing Then
        dbBackend.TableDefs("tblCur").Name = " tblCur " & tdf.datecreated & Format(Date, "yyyymmdd")
         dbBackend.Close
         Else
    Although this doesn't look right.

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If what you want to do is rename the table with tblCur + its own creation date try:

    dbBackend.TableDefs("tblCur").Name = " tblCur " & Format(dbBackend.TableDefs("tblCur").datecreated, "yyyymmdd")

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why are you creating new tables instead of just appending records to existing table with a field for this date value?
    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.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    slimjen,

    With over 500 posts in this forum I think you should be able to give readers a better description of what exactly you are trying to do. People should not have to guess at what you are asking.

    You have told us HOW you have done something, but you have not told us What that something is.

    How about giving us a complete description - simple English?

  8. #8
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    thank you for all of your help and comments

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

Similar Threads

  1. Property sheets
    By RickyBeau03 in forum Programming
    Replies: 4
    Last Post: 12-20-2013, 04:01 PM
  2. Property value is too large
    By Jean Kipling in forum Database Design
    Replies: 3
    Last Post: 01-30-2013, 05:04 PM
  3. Replies: 5
    Last Post: 06-23-2012, 04:30 PM
  4. RecordLocks Property
    By JackieEVSC in forum Forms
    Replies: 5
    Last Post: 11-16-2011, 01:51 PM
  5. SQL vs. vba Row Source property
    By eww in forum Programming
    Replies: 7
    Last Post: 10-15-2010, 11:02 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