Microsoft Access Database Development With VBA

ADOX Topics: Referencing a Table

   

Description

To reference a table in ADOX, first declare a variable of type ADOX.Table. Access the Catalog object of the database that contains the table. Access the Tables indexed property of the Catalog object. Pass the name of the table to this property, and assign this call to the ADOX.Table variable. This would be done as follows:

Private Sub cmdAddColumn_Click()
    Dim catStudents As ADOX.Catalog
    Dim tblStudents As ADOX.Table
    
    Set catStudents = New ADOX.Catalog
    catStudents.ActiveConnection = CurrentProject.Connection
    
    Set tblStudents = catStudents.Tables("Students")
    
    . . . Use the table here

    Set colEmailAddress = Nothing
    Set tblStudents = Nothing
    Set catStudents = Nothing
End Sub
   
     
 

Home Copyright © 2013-2015, FunctionX, Inc. Home