is linkedtable the name of a table or are you trying to use a variable?
The syntax below is correct if linkedtable is a table name, but when I tried
this syntax using it as a variable with a table name it it, I got error 3265
"Item Not Found in this collection." When I use an actual table name, it
worked. Here is a function I know works. It will refresh all the links in
your database:
Private Function ReLink(strNewPath As String) As Boolean
Dim dbs As Database
Dim tdf As TableDef
Dim intCount As Integer
Dim frmCurrentForm As Form
DoCmd.Hourglass True
On Error GoTo ErrLinkUpExit
Me.lblMsg.Visible = True
Me.cmdOK.Enabled = False
Set dbs = CurrentDb
For intCount = 0 To dbs.TableDefs.Count - 1
Set tdf = dbs.TableDefs(intCount)
If tdf.Connect <> "" Then
Me.lblMsg.Caption = "Refreshing " & tdf.NAME
DoEvents
tdf.Connect = ";DATABASE=" & strNewPath
tdf.RefreshLink
End If ' tdf.Connect <> ""
Next intCount
Set dbs = Nothing
Set tdf = Nothing
DoCmd.Hourglass False
Me.lblMsg.Caption = "All Links were refreshed!"
ReLink = True
Me.cmdOK.Enabled = True
Exit Function
"Daniel" wrote:
> When it gives me the error message it does not interupt and highlight a
> specific line?
>
>
>
>
> "Klatuu" wrote:
>
> > Yes, you can set the connect proprerty to anything. It, of course will raise
> > an error when it tries to connect to a backend that has an invalid path.
> >
> > On which line are you getting the error?
> >
> > "Daniel" wrote:
> >
> > > Good morning,
> > >
> > > I would like to be able to change the path of all the linked tables in the
> > > front-end of my application so that when I deliver it to our secondary site,
> > > it is ready to go. \
> > >
> > > I tried the following code that came from another post, but it generates an
> > > error "Compile error: Expected: =" and yet it compiles just fine?
> > >
> > > ****
> > >
> > > Dim db As DAO.database
> > > Dim tdf As DAO.TableDef
> > > Dim strPath As String
> > > strPath = "C:\test\testdb.mdb"
> > >
> > > Set db = CurrentDb()
> > > Set tdf = db.TableDefs!linkedtable
> > > tdf.Connect = ";DATABASE=" & strPath
> > > tdf.RefreshLink
> > > Set tdf = Nothing
> > > Set db = Nothing
> > > ****
> > >
> > > Is it possible to change the path to a structure/dir that does not exists on
> > > the computer I am working on?
> > >
> > > Thank you for your help!
> > >
> > > Daniel
|