Results 1 to 3 of 3
  1. #1
    skydivetom is offline Expert
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    788

    Rename tables -- strip off "suffix" (right)

    Hello:

    I use the VBA (see below) to strip off a "prefix" ("00_LK_) from multiple tables.

    Code:
            For Each tdf In dbs.TableDefs
                If tdf.Name Like "00_LK_*" Then
                tdf.Name = "LK_" & Mid(tdf.Name, 7, 255)
                m = m + 1
            End If
            Next
    Thus, any tables starting with "00_LK_Table_*" will be renamed to "LK_Table_*".

    Using the same logic, how would I strip off a suffix = "_Step_4"? So, a table named "tbl_INJURY_Step_4" would be changed to "tbl_INJURY" while "tbl_ILLNESS_Step_4" would be renamed to "tbl_ILLNESS"?

    Thanks!

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    2,009
    I would investigate the use of the Instr() or RevInstr() functions.

    Linky to assist you https://support.microsoft.com/en-gb/...1-fae75fe5fd56
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    skydivetom is offline Expert
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    788
    Very well... will do. Thanks!

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

Similar Threads

  1. Why can't I see the "Rename" option?
    By rrowsam in forum Access
    Replies: 2
    Last Post: 02-06-2020, 11:12 AM
  2. Simple table relationships ("faces" to "spaces" to "chairs")
    By skydivetom in forum Database Design
    Replies: 36
    Last Post: 07-20-2019, 01:49 PM
  3. Copy Table and rename to "newTable"
    By MadTom in forum Programming
    Replies: 12
    Last Post: 06-13-2018, 08:05 AM
  4. Replies: 4
    Last Post: 09-10-2015, 08:22 AM
  5. Replies: 1
    Last Post: 09-07-2015, 08:00 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