PC Review


Reply
Thread Tools Rate Thread

changeing the connection on a Linked Table

 
 
TADropik
Guest
Posts: n/a
 
      8th Oct 2008
I'm trying to change the connection of "My_Table" which is a linked table.

Dim tdfTarget as TableDef
Set tdfTarget = CurrentDb.TableDefs("MyTable")
With tdfTarget
.Connect = ";Database=" & "C:\Data\My_Data.mdb"
.RefreshLink
End With

If the existing connection to this Table is a Network location
"Z:\Data\My_Data.mdb" and the Network location does not exist, the .Connect
fails.
 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      9th Oct 2008
Just a thought and I have not specifically tested this. You haven't deleted
the link before attempting to change its Path have you?

Your code re-establishes an existing link to a new location; I don't think
that it appends a TableDef. With the code you have you don't delete the link
first.

Anyone else with thoughts on this feel free to express them because I am
also interested if there are instances where this does not work because I use
code in a Switchboard Open event to re-establish links between the FE and BE
which I install in the same folder and can use
Application.CurrentProject.Path to identify the location of the BE when I
move the project to another folder and automate re-establishing the links.

--
Regards,

OssieMac


"TADropik" wrote:

> I'm trying to change the connection of "My_Table" which is a linked table.
>
> Dim tdfTarget as TableDef
> Set tdfTarget = CurrentDb.TableDefs("MyTable")
> With tdfTarget
> .Connect = ";Database=" & "C:\Data\My_Data.mdb"
> .RefreshLink
> End With
>
> If the existing connection to this Table is a Network location
> "Z:\Data\My_Data.mdb" and the Network location does not exist, the .Connect
> fails.

 
Reply With Quote
 
TADropik
Guest
Posts: n/a
 
      9th Oct 2008
Great question.

I have not deleted the link prior to changing the path.

In fact, if I go in to my Link Table Manager, it shows the correct network
path.

What's happening is the Customer is loosing their Network connection.
When that happens I want to automatically link to a local database.


"OssieMac" wrote:

> Just a thought and I have not specifically tested this. You haven't deleted
> the link before attempting to change its Path have you?
>
> Your code re-establishes an existing link to a new location; I don't think
> that it appends a TableDef. With the code you have you don't delete the link
> first.
>
> Anyone else with thoughts on this feel free to express them because I am
> also interested if there are instances where this does not work because I use
> code in a Switchboard Open event to re-establish links between the FE and BE
> which I install in the same folder and can use
> Application.CurrentProject.Path to identify the location of the BE when I
> move the project to another folder and automate re-establishing the links.
>
> --
> Regards,
>
> OssieMac
>
>
> "TADropik" wrote:
>
> > I'm trying to change the connection of "My_Table" which is a linked table.
> >
> > Dim tdfTarget as TableDef
> > Set tdfTarget = CurrentDb.TableDefs("MyTable")
> > With tdfTarget
> > .Connect = ";Database=" & "C:\Data\My_Data.mdb"
> > .RefreshLink
> > End With
> >
> > If the existing connection to this Table is a Network location
> > "Z:\Data\My_Data.mdb" and the Network location does not exist, the .Connect
> > fails.

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      9th Oct 2008
"Customer is loosing their Network connection"
This might be a clue. Try closing the front end and reopening before running
the code. Could be attempting to write to it and can't change the link while
it is waiting to update the table.

--
Regards,

OssieMac


"TADropik" wrote:

> Great question.
>
> I have not deleted the link prior to changing the path.
>
> In fact, if I go in to my Link Table Manager, it shows the correct network
> path.
>
> What's happening is the Customer is loosing their Network connection.
> When that happens I want to automatically link to a local database.
>
>
> "OssieMac" wrote:
>
> > Just a thought and I have not specifically tested this. You haven't deleted
> > the link before attempting to change its Path have you?
> >
> > Your code re-establishes an existing link to a new location; I don't think
> > that it appends a TableDef. With the code you have you don't delete the link
> > first.
> >
> > Anyone else with thoughts on this feel free to express them because I am
> > also interested if there are instances where this does not work because I use
> > code in a Switchboard Open event to re-establish links between the FE and BE
> > which I install in the same folder and can use
> > Application.CurrentProject.Path to identify the location of the BE when I
> > move the project to another folder and automate re-establishing the links.
> >
> > --
> > Regards,
> >
> > OssieMac
> >
> >
> > "TADropik" wrote:
> >
> > > I'm trying to change the connection of "My_Table" which is a linked table.
> > >
> > > Dim tdfTarget as TableDef
> > > Set tdfTarget = CurrentDb.TableDefs("MyTable")
> > > With tdfTarget
> > > .Connect = ";Database=" & "C:\Data\My_Data.mdb"
> > > .RefreshLink
> > > End With
> > >
> > > If the existing connection to this Table is a Network location
> > > "Z:\Data\My_Data.mdb" and the Network location does not exist, the .Connect
> > > fails.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked table connection zz12 Microsoft Access VBA Modules 0 16th May 2007 07:35 PM
Changeing the connection string for a link table Chedva Microsoft Access Form Coding 1 1st Nov 2004 10:43 PM
Changeing the connection string for a link table Chedva Microsoft Access VBA Modules 1 1st Nov 2004 10:43 PM
Changeing the connection string for a link table Chedva Microsoft Access 1 1st Nov 2004 10:43 PM
changeing color of linked text after click jo Microsoft Powerpoint 1 17th Jul 2003 11:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:42 AM.