Add a table to a split database (1 Viewer)

John Sh

Member
Local time
Today, 15:33
Joined
Feb 8, 2021
Messages
410
My database is split with front end, back end.
How do I add a new table other than delete the links in the front end, copy the tables from the back end and then split again.
Is there a way to add the new table without all that rigamarole.
I am currently using the code below to re-link after a back end location change.

Code:
Public Sub re_Link()
    Dim t As TableDef
    Dim td As TableDefs
    Dim sSource As String
    On Error Resume Next
    Set td = oDB.TableDefs                   'oDB from Daniel Pinault's "Shov"
    sSource = TempVars!SRC & "_be.accdb"         'sSource holds the location of the back end files
    For Each t In td
        If t.Connect <> ";DATABASE=" & sSource Then
            t.Connect = ";DATABASE=" & sSource
            t.RefreshLink
        End If
    Next
    Set t = Nothing
    Set td = Nothing
End Sub

This works fine but doesn't include any new tables.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:33
Joined
Oct 29, 2018
Messages
21,473
Have you tried?
1. Open the BE and add the new table there
2. Open the FE and go to External Data and create a new linked table for the new table you just added to the BE
 

John Sh

Member
Local time
Today, 15:33
Joined
Feb 8, 2021
Messages
410
Have you tried?
1. Open the BE and add the new table there
2. Open the FE and go to External Data and create a new linked table for the new table you just added to the BE
Thank you. That works and is easier than what I was doing.
Is there not a way to do this programmatically?
I have three copies of the front end at remote locations and they are all .accde files.
The people operating the front ends would retire rather than try that exercise!
 

ebs17

Well-known member
Local time
Today, 07:33
Joined
Feb 7, 2020
Messages
1,946
Code:
Public Function LinkTable(ByVal TableName As String, _
          ByVal FullPathBE As String) As Boolean
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef

    Set db = CurrentDb
    Set tdf = db.CreateTableDef(TableName)
    tdf.Connect = ";DATABASE=" & FullPathBE
    tdf.SourceTableName = TableName
    db.TableDefs.Append tdf
    LinkTable = True
End Function
You can also use the TransferDatabase method.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:33
Joined
Feb 19, 2013
Messages
16,612
Assuming they are using the same back end send them a copy of your file as a .accde?
 

John Sh

Member
Local time
Today, 15:33
Joined
Feb 8, 2021
Messages
410
Code:
Public Function LinkTable(ByVal TableName As String, _
          ByVal FullPathBE As String) As Boolean

[/QUOTE]
Thank you ebs17. That looks like the answer.
 

Users who are viewing this thread

Top Bottom