Question : Link tables manager

g'day,

I have a database in which I use the link tables manager to change the links when/if required. This works well enough but, in cases where there is a problem, it crushes and shows error 2046 'tables links manager not available right now' (or something similar).

The code involves the deletion of any previously attached table links before allowing to link to a new database. I don't understand exactly where the problem lays but here's the layout:

The database window is hidden,
only short cut menus are available,
code such DoCmd.RunCommand acCmdLinkTables returns the same error,
if I allow full menus File/Get External Data is dimmed out,
if I show the database window it all works ok.

Anybody can help?

thanks

Dave

Answer : Link tables manager

do you WANT to use the linked table manager?  there are alternatives, for example using the Connect property of the table, like in this sample code:

  On Error Resume Next

  Dim db As Database
  Dim myTable As TableDef
   
  Set db = CurrentDb()
  Set myTable = db.TableDefs("MyTableName")
  If Len(myTable.Connect) > 0 Then
    ' this table is linked -> relink it      
    myTable.Connect = ";DATABASE=" & "C:\my\new\database.mdb"
    myTable.RefreshLink
    If Err.number <> 0 Then
      MsgBox "Relink table '" & tableName & "' failed."
    End If
  End If


of course, instead of hard-coding the new database (like "C:\my\new\database.mdb" in the example), you can use a dialog box to ask the user for the new path (e.g., see here: http://www.mvps.org/access/api/api0001.htm)


--bluelizard
Random Solutions  
 
programming4us programming4us