CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    Reykjavik,Iceland
    Posts
    25

    Adding fields from a code

    Hello

    I need to add a field to a Access database from a VisualBasic code

    (and delete one field)

    Can anyone advice on this ??

    Thanks


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Adding fields from a code

    if you use DAO to access your jet database, check out the TableDefs collection.

    sample


    Dim db as DAO.Database
    set db = OpenDatabase("m:\daten\projekt\test.mdb")
    Dim td as DAO.TableDef
    set td = db.TableDefs("test2")
    td.fields.remove("PK") ' remove
    ' add new fields
    Dim fld as DAO.Field
    set fld = td.createField("pk", dbLong)
    fld.attributes = dbAutoIncrField
    td.fields.append





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured