Programatically change linked tables

ColeChaW

Charlie
Local time
Yesterday, 22:52
Joined
Aug 10, 2006
Messages
36
I'm trying to change linked tables from pointing to a SQL server database to pointing to a local copy when offline.

I cannot figure out how to change the tabledef.attributes tag. I need to switch it between dbAttachedODBC and dbAttachedTable, I think. :confused:

Code:
    For Each TBDef In CurDB.TableDefs
            Set tdfLinked = CurDB.TableDefs(TBDef.Name)
            If SetOnline Then
                tdfLinked.Attributes = tdfLinked.Attributes Or dbAttachedODBC
            Else
                tdfLinked.Attributes = (tdfLinked.Attributes And Not dbAttachedODBC) 'dbAttachedTable
            End If
            tdfLinked.Connect = DBPath
            tdfLinked.RefreshLink
    Next TBDef

Is this possible or should I do something else???

Thanks. :D
 
Simple Software Solutions

Here is some documentation on how I switch between servers and local machines.

May be a bit more code but it has more error checking and so on.

CodeMaster::cool:
 

Attachments

Working well going through the tables but when it hits one of the ODBC tables that I'm trying to link to an Access database, it opens a dialog box that asks me to select Data Source to use. I'm stumped.:(
 

Users who are viewing this thread

Back
Top Bottom