Hi Jac
sPrev is explained as follows.
In theory, you can have tables that are linked to *many* external
databases. Indeed, every single table, could be linked to a different
external database.
However, when I designed this particular function, I designed it for
the case where *all* of the linked tables are in *one* external
database. That is a design constraint of this function.
To program the function, we need to loop through all the tabledef's,
until we find one that is linked. (You might have a mixture of linked
tables and local (unlinked) ones in the same database.) We check for a
linked table by looking at its CONNECT property.
Once we find the first linked table, we get the name of the external
database file, from the CONNECT property.
The question is, what to do then?
Basically, we have two options:
(1) *Assume* that any further linked tables will be in the same
external file, or
(2) *Check* that any further linked tables *are* in the same external
file.
I chose to do (2). For the first linked table that it finds, it gets
the name of the external file, and stores that name in sName. Then it
says: "Oh, I'll just remember that for later", and copies it to sPrev.
Then for each successive linked table, it gets the name of the external
file (in sName), and then says: "Um, is that the same name that we got
before"? It does that by comparing sName to sPrev.
It may help to "hand simulate" the code. Say you have 3 linked tables,
the first is linked to external database file "a.mdb", and the second
and third to external file "b.mdb". Then execute the code as if you
were the cenbtral processing unit! Write down the value of sName and
sPrev on each loop. You'll soon see how the code detects the case where
there is more than one external file.
HTH,
TC (MVP Access)
http://tc2.atspace.com