Results 1 to 2 of 2

Thread: How do I rename a MS Access Table ??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Post

    Hi, is it possible to rename a MS-Access Table in VB, and if so How?

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    Yes, certainly!

    The follow code change name Table1 to Table2 in MS Access database.

    Code:
    Dim dbTest As Database
    Dim tblObj As DAO.TableDef
    Dim sTBLName As String
    Dim bIncludeSysTables As Boolean
            
        Set dbTest = OpenDatabase("d:\db1.mdb", True)
      
        For Each tblObj In dbTest.TableDefs
            If (tblObj.Attributes And dbSystemObject) = 0 Or bIncludeSysTables Then
              sTBLName = tblObj.Name
              If sTBLName = "Table1" Then tblObj.Name = "Table2"
            End If
        Next
    
        dbTest.Close
    Best regards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width