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

    rename twice

    All, using access 2010. I have this code below to open backend and renaming a tbl with the current date. Ex. tblMstr to tblMstr20140922. This is so a table with the same name can be imported. tblMstr. This works great. My problem is when users have to reimport the same day they get something like “tblMstr20140922 already exist.” How do I fix this? If the same date already exist; I need it to override or something. Anyone have any suggestions to fix this please?

    Code:
    Dim dbBackend As DAO.Database
    Dim strBackendDatabase As String
      strBackendDatabase = "C:\TestFolder\Sampledb.accdb"
      Set dbBackend = OpenDatabase(strBackendDatabase)
    dbBackend.TableDefs("tblMstr").Name = "tblMstr" & Format(Date, "yyyymmdd")
      dbBackend.Close
      Set dbBackend = Nothing


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Dont use tables with date names. It makes the queries useless.
    DO contain a date stamp in the table to show the data date...(irrelevant to queries)
    Do put a date on the db name to archive it. The queries will still work this way too.

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    I apologize for the misunderstanding. The date is to archive the file. No to use in the query. It’s just that the user may have to archive a table twice due to an error the first time in one day. So what do I do if this happens and the file already has a file with the same date? Thanks

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

Similar Threads

  1. rename object
    By slimjen in forum Forms
    Replies: 8
    Last Post: 07-18-2014, 04:03 PM
  2. import and rename
    By slimjen in forum Import/Export Data
    Replies: 1
    Last Post: 07-02-2014, 11:05 PM
  3. rename a PDF File
    By sdel_nevo in forum Programming
    Replies: 3
    Last Post: 08-21-2013, 12:11 PM
  4. rename
    By slimjen in forum Access
    Replies: 3
    Last Post: 03-11-2013, 02:10 PM
  5. rename ole object
    By rbg in forum Access
    Replies: 0
    Last Post: 11-29-2010, 03:13 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