Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Create a Table with Jet Data Types via ADOX


View products that this article applies to.

This article was previously published under Q275252
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access database (.mdb).

↑ Back to the top


Summary

This article contains an ActiveX Extensibility Objects (ADOX) example that demonstrates a way to create a native Jet table with some of the common Jet data types and properties.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following Visual Basic for Applications example creates in the current database a table with some of the common data types and properties, such as AutoNumber, Decimal, Memo, and Text.

NOTE: Before you run the code, click References on the Tools menu, and make sure that you have the following reference selected:
Microsoft ADO Ext. 2.x for DDL and Security
Sub ADOX_CreateJetTable()

'This example demonstrates creating a Jet table with
'Autoincrement, Decimal, and Memo columns.

Dim tbl As New ADOX.Table
Dim cat As New ADOX.Catalog

'Return Reference to current database.
Set cat.ActiveConnection = CurrentProject.Connection

'Assign the new table name.

With tbl
  .Name = "MyNewTable"

    ' Append new columns to the table.
    With .Columns
      .Append "MyID", adInteger
      .Append "MyMemo", adLongVarWChar
      .Append "MyVarChar", adWChar, 50
      .Append "MyDecimal", adNumeric
    
            'After appending columns, set
            'provider specific properties.
            With !MyID
                Set .ParentCatalog = cat
                    .Properties("Autoincrement") = True
                    .Properties("seed") = CLng(20)
                    .Properties("increment") = CLng(20)
            End With
    
    
            With !MyDecimal
                Set .ParentCatalog = cat
                    .Precision = 2
                    .NumericScale = 1
            End With
    
            With !MyVarChar
                Set .ParentCatalog = cat
                    .Properties("Jet OLEDB:Compressed " _
                                & "UniCode Strings") = True
            End With
    
    End With
End With

' Append new table to the provider catalog and clean up.
cat.Tables.Append tbl
Set cat = Nothing

End Sub
				

↑ Back to the top


Keywords: KB275252, kbhowto

↑ Back to the top

Article Info
Article ID : 275252
Revision : 3
Created on : 6/23/2005
Published on : 6/23/2005
Exists online : False
Views : 288