
Copying table structures in code
: We are converting from Access2.0 to Access97 and I have run into a
: problem with some code.
: I have a sub that used the "CopyObject" method and it worked well
: enough in version 2. The source was an attached table and the
: destination was a local table with a temp name. The method would
: read the structure and data from the attached table and create a
: local (non-attached) table identical to the original. It was then a
: simple matter to run an SQL to strip the data out if I didn't want.
: In Access 97 I get another attached table pointing to the same
: "real" table as the original attached table.
:..............................
Looks like there is a change of behaviour here.
The online help states that the CopyObject has the same effect as
using Copy and Paste. This seems true enough ... but in V2 as you say
both methods created a local copy and now in 97 (not sure about 95)
both methods create a duplicate link.
The work-around to emulate the CopyObject would be to execute a simple
MakeTable query. It could either be a saved query (executed via code
or macro) or dynamic SQL generated in code to suit.
Something like :
Dim strSQL as string
strSQL = "SELECT tblOne.* INTO temp FROM tblOne;"
Currentdb.execute strSQL
-- Chris Bell --