Reference column name from TableDefs : TableDefs « Access « VBA / Excel / Access / Word






Reference column name from TableDefs

 
Sub exaCurrentDb2()
    Dim dbOne, dbTwo As Database
    Dim fldNew As Field
    Dim str As String
    
    Set dbOne = CurrentDb
    Set dbTwo = CurrentDb
    For Each fldNew In dbOne.TableDefs!BOOKS.Fields
        Debug.Print fldNew.Name
    Next
    
    Set fldNew = dbOne.TableDefs!BOOKS.CreateField("NewField1", dbInteger)
    dbOne.TableDefs!BOOKS.Fields.Append fldNew
    
    Set fldNew = dbTwo.TableDefs!BOOKS.CreateField("NewField2", dbInteger)
    dbTwo.TableDefs!BOOKS.Fields.Append fldNew
    
    dbOne.TableDefs!BOOKS.Fields.Refresh
    
    For Each fldNew In dbOne.TableDefs!BOOKS.Fields
        Debug.Print fldNew.Name 
    Next
    For Each fldNew In dbTwo.TableDefs!BOOKS.Fields
        Debug.Print fldNew.Name
    Next
    dbOne.Close
    dbTwo.Close
End Sub

 








Related examples in the same category

1.Database relations
2.Add new property to TableDef
3.List table properties
4.Create a relation
5.Create an index
6.Create new field with validation rule