DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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)



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links