Microsoft KB Archive/304100

= How To Use ADO to Determine If a Field Is an AutoNumber Field in an Access Table =

Article ID: 304100

Article Last Modified on 8/30/2004

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6

-



This article was previously published under Q304100



SUMMARY
Using the Microsoft OLE DB Provider for Jet 4.0 in ADO, you can use the dynamic property ISAUTOINCREMENT to determine if a field is an AutoNumber field. This property also allows you to determine if the field is an Identity field in a Microsoft SQL Server table.



MORE INFORMATION
The following code illustrates the use of the dynamic property ISAUTOINCREMENT: Dim cn As ADODB.Connection strConnect = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; & _ &quot;Data Source= ;Persist Security Info=False&quot;

Set ADOCon = New ADODB.Connection With ADOCon .ConnectionString = strConnect .Open End With Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset rs.ActiveConnection = ADOCon rs.CursorLocation = adUseServer rs.CursorType = adOpenStatic rs.Open &quot;Select * from table1&quot; For x = 0 To rs.Fields.Count - 1 If rs.Fields(x).Properties(&quot;ISAUTOINCREMENT&quot;) = True Then MsgBox &quot;Field &quot; & rs.Fields(x).Name & &quot; is Autoincrement&quot; End If Next x

Keywords: kbhowto KB304100

-

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

© Microsoft Corporation. All rights reserved.