Stuart McLachlan
stuart at lexacorp.com.pg
Wed Jul 2 17:51:50 CDT 2003
On 2 Jul 2003 at 6:58, Sad Der wrote:
> Hi Group,
>
> does anybody know how i can automaticle relink tables?
>
Here's the code that I use. It assumes that the BE and FE are in the
same directory.
As someone pointed out on the list the
"If Left$(tdfloop.Connect, 10) = ";DATABASE=" " can fail under
certain circumstances (I can't remember the details, but under some
setups, there is another parameter bfore the "DATABASE" - can anyone
refresh my memory?). This has always worked in my apps though.
Option Compare Database
Option Explicit
Function RelinkTables() As Long
Dim tdfloop As TableDef
With CurrentDb
For Each tdfloop In .TableDefs
If Left$(tdfloop.Connect, 10) = ";DATABASE=" Then _
tdfloop.Connect = ";DATABASE=" & ApplDir & _
filename(Mid$(tdfloop.Connect, 11))
tdfloop.RefreshLink
End If
Next tdfloop
End With
End Function
Function pathname(fullpath As String) As String
Dim STemp As String
pathname = Left$(fullpath, InStrRev(fullpath, "\"))
End Function
Function filename(fullpath As String) As String
Dim STemp() As String
STemp() = Split(fullpath, "\")
filename = STemp(UBound(STemp))
End Function
Static Function ApplDir() As String
Dim strApplDir As String
Dim strTemp As String
If strApplDir = "" Then
strTemp = DBEngine(0)(0).Name
strApplDir = Left$(strTemp, InStrRev(strTemp, "\"))
End If
ApplDir = strApplDir
End Function
--
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System
Support.