L
LarryP
MSAccess 2003 on Windows XP Pro.
Function below fails at the <tdfLinked.Connect = > step. Throws a "runtime
error 3420, Object invalid or no longer set." FYI, SessionFilePath is a
global variable containing the first part of the filepath for the table link,
while rsLinkedTables!xxxxxxxxxx is the second part of the filepath, down to
the actual filename. (E.g., SessionFilePath = "\\aaaa\bbb\cccccccc\", and
rsLinkedTables!xxxxxxxxx = "ddd\eeeee\fff ggggg.mdb") Who can tell me
what I'm doing wrong?
Public Function SetLinksBySite()
Dim tdfLinked As TableDef, rsLinkedTables As Object
DoCmd.RunSQL "UPDATE tblLinkedTables SET OffsiteLinkSet = False"
Set rsLinkedTables = CurrentDb.OpenRecordset("tblLinkedTables")
rsLinkedTables.MoveFirst
Do While Not rsLinkedTables.EOF
Set tdfLinked = CurrentDb.TableDefs(rsLinkedTables!TableName)
If SessionSite = "Tucson" Then
tdfLinked.Connect = "DATABASE=" & SessionFilePath &
rsLinkedTables!TucsonTableLink
Else
tdfLinked.Connect = "DATABASE=" & SessionFilePath &
rsLinkedTables!OffsiteTableLink
End If
tdfLinked.RefreshLink
rsLinkedTables!TableLinkRefreshed = True
rsLinkedTables.MoveNext
Loop
End Function
Function below fails at the <tdfLinked.Connect = > step. Throws a "runtime
error 3420, Object invalid or no longer set." FYI, SessionFilePath is a
global variable containing the first part of the filepath for the table link,
while rsLinkedTables!xxxxxxxxxx is the second part of the filepath, down to
the actual filename. (E.g., SessionFilePath = "\\aaaa\bbb\cccccccc\", and
rsLinkedTables!xxxxxxxxx = "ddd\eeeee\fff ggggg.mdb") Who can tell me
what I'm doing wrong?
Public Function SetLinksBySite()
Dim tdfLinked As TableDef, rsLinkedTables As Object
DoCmd.RunSQL "UPDATE tblLinkedTables SET OffsiteLinkSet = False"
Set rsLinkedTables = CurrentDb.OpenRecordset("tblLinkedTables")
rsLinkedTables.MoveFirst
Do While Not rsLinkedTables.EOF
Set tdfLinked = CurrentDb.TableDefs(rsLinkedTables!TableName)
If SessionSite = "Tucson" Then
tdfLinked.Connect = "DATABASE=" & SessionFilePath &
rsLinkedTables!TucsonTableLink
Else
tdfLinked.Connect = "DATABASE=" & SessionFilePath &
rsLinkedTables!OffsiteTableLink
End If
tdfLinked.RefreshLink
rsLinkedTables!TableLinkRefreshed = True
rsLinkedTables.MoveNext
Loop
End Function