Access VBA Error trying to create column for linked table

Murray Brown
Murray Brown used Ask the Experts™
on
In trying to create an Access column in a linked table I get the error "Operation is not supported in linked tables"
Is there a way to do this where the tables are linked

Sub oCheck_Add_Columns()

    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Dim blnFieldExists As Boolean
    Set dbs = CurrentDb()
    Set tdf = dbs.TableDefs("Ammunition")
    For Each fld In tdf.Fields
        If fld.Name = "CreatedDTG" Then
            blnFieldExists = True
            Exit For
        End If
    Next
   
    If Not blnFieldExists Then
        Set fld = tdf.CreateField("CreatedDTG", dbDate)
        fld.DefaultValue = "=Now()"
        tdf.Fields.Append fld
    End If
   
End Sub
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
President / Owner CARDA Consultants Inc.
Distinguished Expert 2018
Commented:
Normally, design changes are does in the back-end directly on the table itself.

If you truly want to venture down this road, then you need to get into accessing the back-end through code and then automating it.  There are different ways of doing this.  One example would be https://access-programmers.co.uk/forums/showpost.php?p=326583&postcount=10
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Great answer! Thanks very much Daniel

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial