Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disconnect from File/Table

Status
Not open for further replies.

srmclean

Technical User
Jun 23, 2003
23
0
0
AU
There was a thread previous about disconnecting from a file. The reply was to delete the linked table using :

dbasetempname.TableDefs.Delete Tablename

I've been using this and it seemed fine, until now.

I connect to a remote file's table via this code :

Set tdfLink = CurrentDb.CreateTableDef(NewTable)
tdfLink.Connect = ";DATABASE=" & FileLocation
tdfLink.SourceTableName = SourceTable
CurrentDb.TableDefs.Append tdfLink

and was disconnecting the table via :

CurrentDb.TableDefs.Delete LinkedTable

Now the file I connect to is a .mdb file created by some 3rd party software.

If I run this 3rd party software while my Access application is not running - no problem - as you'd expect.

If I run this 3rd party software while my Access application is running and I've connected to the tables - problem - 3rd party software throws a fit saying the file has been opened for exclusive use by another - as you'd expect.

If I run this 3rd party software while my Access application is running and I've connected and then disconnected (using the delete table method) - 3rd party software throws a fit.

So I conclude that deleting the table doesn't actually disconnect you from the remote file.

The question is how do you disconnect from a file and undo the

tdfLink.Connect = ";DATABASE=" & FileLocation

as surely this is the only place a link to the table above is created?

Thanks,

Shaun



----------------
Shaun McLean
 
I don't know the command off hand but, Often Shaun, just closing any tables, forms reports SQL's, that use that table, disconnects it?
 

Ok, I found that I still had a form open that was looking at the "deleted" table. So I guess it was keeping the link alive. Now when I disconnect I close that form and I have no problems. Thanks.

----------------
Shaun McLean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top