Microsoft KB Archive/275252

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

Article ID: 275252

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



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).



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.



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 = &quot;MyNewTable&quot;

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

Keywords: kbhowto KB275252

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.