Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Relink table with code 1

Status
Not open for further replies.

Spyder1000

Technical User
Nov 2, 2004
109
US
I've got a database front end and backend. I've developed my database on one PC but I need to move it to a PC that does not use the same drives.

I'd like to create a button that when pressed brought up a prompt to find the new location of the database and reconnect the tables.

Any help?
 
Code:
Public Sub RelinkTables(NewPathname As String)
    Dim Dbs As Database
    Dim Tdf As TableDef
    Dim Tdfs As TableDefs
    Set Dbs = CurrentDb
    Set Tdfs = Dbs.TableDefs
'Loop through the tables collection
       For Each Tdf In Tdfs
        If Tdf.SourceTableName <> "" Then 'If the table source is other than a base table
            Tdf.Connect = ";DATABASE=" & NewPathname 'Set the new source
            Tdf.RefreshLink 'Refresh the link
        End If
    Next 'Goto next table
End Sub

as found on


-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top