appending new field in an existing table in VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sahumukesh
    New Member
    • Jul 2008
    • 1

    appending new field in an existing table in VBA

    hi friend!
    i have a chalanging problem for you all.i have an existing table with Name and address fields containing few records in it and want to append one autonumber field ie SNo to this table in MS ACCESS using VBA/DAO.
    is there any one who can solve my problem?
    if yes please provide the code.
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    I have to ask, why in the world would you need to do this thru VBA?

    Here is a hack I found for you:
    Code:
    Dim tbl As TableDef  
      
    Dim field As field  
      
    Set tbl = db.TableDefs(strTableName)  
      
    Set field = tbl.CreateField(Name:=strFieldNametoAdd,Type:=FieldType)  
      
    If (db.Updatable And tbl.Updatable) Then  
      
    tbl.Fields.Append field tbl.Fields.Refresh  
      
    Else  
      
    MsgBox "not updatable"  
      
    End If
    Welcome to Bytes!

    Linq ;0)>

    Comment

    Working...