Hi
I am trying to refresh table links at startup in an Access 2002
application. The following code is based on a number of articles
posted in this group but this does not seem to work:
===CODE SNIPPET START===
For i = 0 To CurrentDb.TableDefs.Count - 1
If Left(CurrentDb.TableDefs(i).NAME, 3) = "tbl" Then
CurrentDb.TableDefs(i).Properties("Connect") =
constODBC_ConnectString
CurrentDb.TableDefs(i).Properties.Refresh
CurrentDb.TableDefs(i).RefreshLink
MsgBox CurrentDb.TableDefs(i).NAME & vbCrLf & vbCrLf &
CurrentDb.TableDefs(i).Connect
End If
Next i
===CODE SNIPPET END===
I also tried:
===CODE SNIPPET START===
For i = 0 To CurrentDb.TableDefs.Count - 1
If Left(CurrentDb.TableDefs(i).NAME, 3) = "tbl" Then
CurrentDb.TableDefs(i).Connect = constODBC_ConnectString
CurrentDb.TableDefs(i).RefreshLink
MsgBox CurrentDb.TableDefs(i).NAME & vbCrLf & vbCrLf &
CurrentDb.TableDefs(i).Connect
End If
Next i
===CODE SNIPPET END===
constODBC_ConnectString is a global string variable containing a valid
connect string.
No errors are generated but the Connect property does not get updated
in either case. The original (manually linked) connect property is
maintained.
Please help.