Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Access VBA Error trying to create column for linked table

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
    If Not blnFieldExists Then
        Set fld = tdf.CreateField("CreatedDTG", dbDate)
        fld.DefaultValue = "=Now()"
        tdf.Fields.Append fld
    End If
End Sub
Avatar of Daniel Pineault
Daniel Pineault

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown


Great answer! Thanks very much Daniel