Results 1 to 7 of 7
  1. #1
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    Unanswered: CurrentData.AllTables no good in 97

    Works in 2k and gretaer but not 97

    Below code has been mainstay for me to rename reattached sql tables - but now it fails in 97 (I know 97 but I do not have a choice - that is what the client is using)

    Any suggestions


    Dim accObject As Object

    'Fill with Tables
    For Each accObject In CurrentData.AllTables
    If left(accObject.Name, 4) = "dbo_" Then
    Dim mynewname, mylen
    mylen = Len(accObject.Name) - 4

    DoCmd.Rename Right(accObject.Name, mylen), acTable, accObject.Name

    DoCmd.Rename mnewname, acTable, accObject.Name
    End If
    Next
    MsgBox "Done"
    Dale Houston, TX

  2. #2
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    I hate when I answer my own questions

    this seems to work - but I do not like it

    Dim DocumentCounter As Integer
    Dim db As Database
    Set db = CurrentDb
    For DocumentCounter = 0 To db.Containers("Tables").Documents.Count - 1
    If left$(db.Containers("Tables").Documents(DocumentCo unter).Name, 4) = "dbo_" Then

    Debug.Print db.Containers("Tables").Documents(DocumentCounter) .Name

    End If
    Next DocumentCounter

    I can then use rename code - at least this works for the tables container.
    Dale Houston, TX

  3. #3
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    Acc 97 rename dbo_ code solution - sorry for the wasted post

    Code:
    Dim DocumentCounter As Integer
    Dim db As Database
    Set db = CurrentDb
    For DocumentCounter = 0 To db.Containers("Tables").Documents.Count - 1
        If left(db.Containers("Tables").Documents(DocumentCounter).Name, 4) = "dbo_" Then
                 Dim mynewname, mylen
            mylen = Len(db.Containers("Tables").Documents(DocumentCounter).Name) - 4
            DoCmd.Rename Right(db.Containers("Tables").Documents(DocumentCounter).Name, mylen), _
                acTable, db.Containers("Tables").Documents(DocumentCounter).Name
            
        End If
        
    Next DocumentCounter
    EDIT: (georgev) [CODE] tags added to retain formatting (and therefore readability)
    Last edited by gvee; 11-06-07 at 13:24.
    Dale Houston, TX

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I have a solution like this somewhere - it's a shame you beat me to it

    Well done for working it out yourself and thanks for sharing the results Dale!
    George
    Home | Blog

  5. #5
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    I hate posting my own solutions.

    I sure like the currentdata way though
    Dale Houston, TX

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Answering your own problems is a sign that you're "31337"

    It's nice to see someone who still tries to solve a problem and not wait for someone else to do it for them
    George
    Home | Blog

  7. #7
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    terrible that I actually understand 31337
    Dale Houston, TX

Posting Permissions

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