M
Mark
I use the following code to switch the links of a master FE, using a listbox
filled with various BE/Path combinations. This code works perfectly in that
all the tables are relinked and I can immediately open any table and be
editing the correct BE. I'm running into an inconsistent problem, however,
concerning which BE is "open", judging by the .ldb file appearing in
Windows Explorer. Sometimes, the .ldb for the initial BE still exists even
though the FE has been linked to another BE and the FE correctly opens and
edits this second BE. Note that this is on a single-user, non-networked
computer. Right now I can't seem to recreate the problem, but it (really!)
did occur earlier.
While this hasn't resulted in any problems at all in using a master FE and
then relinking to other BE's as needed, it has prevented me from being able
to update a user's BE by temporarily linking to another file, swapping the
old BE with the new one, and then relinking back to this new BE. Even
though the relinking occurs to the temporary file, the original BE .ldb file
remains in existance, thus preventing the swapping of the new and old BE's.
The code I'm using is as follows. I would sure appreciate any help on how to
fully close the originally-linked BE after linking to the temporary file.
Thanks,
Mark.
(apologies to John Hawkins if I've altered any of his code)
'RelinkTables...Just as the name suggests pass a path to a database to this
sub
'eg RelinkTables("c:\windows\test.mdb")
'and it will go through all the tables in your
'database and link them to the new location
'Written by John Hawkins 20/9/99 www.fabalou.com
Dim dbs As Database
Dim tdf As TableDef
Dim Tdfs As TableDefs
Dim NewPathname As String
Set dbs = CurrentDb
Set Tdfs = dbs.TableDefs
NewPathname = Forms!Admin_Defaults!RelinkListBox
'Loop through the tables collection
For Each tdf In Tdfs
If tdf.SourceTableName <> "" Then
tdf.Connect = ";DATABASE=" & NewPathname
tdf.RefreshLink 'Refresh the link
End If
Next 'Goto next table
End Sub
filled with various BE/Path combinations. This code works perfectly in that
all the tables are relinked and I can immediately open any table and be
editing the correct BE. I'm running into an inconsistent problem, however,
concerning which BE is "open", judging by the .ldb file appearing in
Windows Explorer. Sometimes, the .ldb for the initial BE still exists even
though the FE has been linked to another BE and the FE correctly opens and
edits this second BE. Note that this is on a single-user, non-networked
computer. Right now I can't seem to recreate the problem, but it (really!)
did occur earlier.
While this hasn't resulted in any problems at all in using a master FE and
then relinking to other BE's as needed, it has prevented me from being able
to update a user's BE by temporarily linking to another file, swapping the
old BE with the new one, and then relinking back to this new BE. Even
though the relinking occurs to the temporary file, the original BE .ldb file
remains in existance, thus preventing the swapping of the new and old BE's.
The code I'm using is as follows. I would sure appreciate any help on how to
fully close the originally-linked BE after linking to the temporary file.
Thanks,
Mark.
(apologies to John Hawkins if I've altered any of his code)
'RelinkTables...Just as the name suggests pass a path to a database to this
sub
'eg RelinkTables("c:\windows\test.mdb")
'and it will go through all the tables in your
'database and link them to the new location
'Written by John Hawkins 20/9/99 www.fabalou.com
Dim dbs As Database
Dim tdf As TableDef
Dim Tdfs As TableDefs
Dim NewPathname As String
Set dbs = CurrentDb
Set Tdfs = dbs.TableDefs
NewPathname = Forms!Admin_Defaults!RelinkListBox
'Loop through the tables collection
For Each tdf In Tdfs
If tdf.SourceTableName <> "" Then
tdf.Connect = ";DATABASE=" & NewPathname
tdf.RefreshLink 'Refresh the link
End If
Next 'Goto next table
End Sub