How to add a new field in an existing Access 97 table?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to add a new field in an existing Access 97 table?

  1. #1
    Giampiero Guest

    How to add a new field in an existing Access 97 table?


    How can I add a new field in an existing Access 97 table? Where can I find
    an example?

    Bye

    Giampiero

  2. #2
    Paul Clement Guest

    Re: How to add a new field in an existing Access 97 table?

    On 5 Mar 2001 09:23:15 -0800, "Giampiero" <giampiero@powersoft.it> wrote:


    How can I add a new field in an existing Access 97 table? Where can I find
    an example?


    You can use ADOX (Microsoft ADO Ext for DDL and Security) to do this:

    Sub AddFields()

    Dim col As New ADOX.Column
    Dim cat As New ADOX.Catalog

    'Engine Type=4 is Access 97 and a value of 5 is Access 2000
    cat.ActiveConnection = _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:\My Documents\db1.mdb;" & _
    "Jet OLEDB:Engine Type=4;"

    col.NAME = "Column1"
    col.Type = adLongVarWChar
    cat.Tables("Table1").Columns.Append col
    Set col = New ADOX.Column
    col.NAME = "Column2"
    col.Type = adBoolean
    cat.Tables("Table1").Columns.Append col
    Set col = New ADOX.Column
    col.NAME = "Column3"
    col.Type = adVarChar
    cat.Tables("Table1").Columns.Append col

    cat.Tables("Table1").Columns("Column1").Properties("Jet OLEDB:Allow Zero Length").Value = True
    cat.Tables("Table1").Columns("Column2").Properties("Jet OLEDB:Allow Zero Length").Value = True
    cat.Tables("Table1").Columns("Column3").Properties("Jet OLEDB:Allow Zero Length").Value = True

    Set cat = Nothing

    End Sub


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  3. #3
    Giampiero Guest

    Re: How to add a new field in an existing Access 97 table?


    Thank you very much. IT WORKS!!!!

    Giampiero

    Paul Clement <UseAdddressAtEndofMessage@swspectrum.com> wrote:
    >On 5 Mar 2001 09:23:15 -0800, "Giampiero" <giampiero@powersoft.it> wrote:
    >
    >
    > How can I add a new field in an existing Access 97 table? Where can I

    find
    > an example?
    >
    >
    >You can use ADOX (Microsoft ADO Ext for DDL and Security) to do this:
    >
    >Sub AddFields()
    >
    >Dim col As New ADOX.Column
    >Dim cat As New ADOX.Catalog
    >
    >'Engine Type=4 is Access 97 and a value of 5 is Access 2000
    >cat.ActiveConnection = _
    > "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    > "Data Source=c:\My Documents\db1.mdb;" & _
    > "Jet OLEDB:Engine Type=4;"
    >
    >col.NAME = "Column1"
    >col.Type = adLongVarWChar
    >cat.Tables("Table1").Columns.Append col
    >Set col = New ADOX.Column
    >col.NAME = "Column2"
    >col.Type = adBoolean
    >cat.Tables("Table1").Columns.Append col
    >Set col = New ADOX.Column
    >col.NAME = "Column3"
    >col.Type = adVarChar
    >cat.Tables("Table1").Columns.Append col
    >
    >cat.Tables("Table1").Columns("Column1").Properties("Jet OLEDB:Allow Zero

    Length").Value
    >= True
    >cat.Tables("Table1").Columns("Column2").Properties("Jet OLEDB:Allow Zero

    Length").Value
    >= True
    >cat.Tables("Table1").Columns("Column3").Properties("Jet OLEDB:Allow Zero

    Length").Value
    >= True
    >
    >Set cat = Nothing
    >
    >End Sub
    >
    >
    >Paul ~~~ pclement@ameritech.net
    >Microsoft MVP (Visual Basic)



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center