Tom,
MyDatabase in MyDatabase.TableDefs(i).Name = refers to D:\NWNKBE.mdb so your
code is renaming the tables in D:\NWNKBE.mdb.
Consider using TransferDataBase to link all the tables in D:\NWNKBE.mdb to
your local database. You can assign the names you want for the linked tables
directly in the TransferDatabase method.
DoCmd.TransferDatabase [transfertype], databasetype, databasename[,
objecttype], source, destination[, structureonly][, saveloginid]
Assign the names you want for the linked tables in the destination
parameter.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help
(E-Mail Removed)
"Tom Ellison" <(E-Mail Removed)> wrote in message
news:uK7NSd$(E-Mail Removed)...
> Please consider this VBA code:
>
> Dim MyDatabase As Database, i As Integer
>
> Set MyDatabase = OpenDatabase("D:\NWNKBE.mdb")
> For i = 0 To MyDatabase.TableDefs.Count - 1
> If Left(MyDatabase.TableDefs(i).Properties(0), 4) <> "MSys" Then
> Debug.Print MyDatabase.TableDefs(i).Name
> MyDatabase.TableDefs(i).Name = "NK" &
> MyDatabase.TableDefs(i).Name
> CurrentDb.TableDefs.Append MyDatabase.TableDefs(i)
> End If
> Next i
>
> There is a surprising result to this code. The table names in the NWNKBE
> database are actually being changed! I had expected the local copy of it
> to be changed, not the original.
>
> What I'd like to do is to create a set of uniquely named linked tables
> from a set of 3 databases, all verisons of Northwind. So, they all have
> the same set of tables, names and all. I just want to have uniquely named
> links to them. I can do that manually quite easily.
>
> Thanks for your advice on this. I'll be looking at all the books for
> information, too.
>
> Tom Ellison
>
>