Add a table to a split database

John Sh

Member
Local time
Tomorrow, 06:17
Joined
Feb 8, 2021
Messages
506
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.
 
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
 
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!
 
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.
 
Assuming they are using the same back end send them a copy of your file as a .accde?
 
Alternatively (assuming you've built the new table in your front end) simply use DoCmd.TransferDatabase with TransferType:=acExport ObjectType:=acTable etc .... to move it the BE and the DoCmd.TransferDatabase TransferType:=acLink ObjectType:=acTable etc .... to link to it.
 

Users who are viewing this thread

Back
Top Bottom