Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set column "Identity" property. Append a new table in an Access Projec 1

Status
Not open for further replies.

MaltaC

Technical User
Jun 9, 2005
15
US
I am appending a new table in an Access Project. I am trying to set the "Identity" property (autoincrement) of the first column in the table. I receive the following error message:

"run time error 3265, Item cannot be found in the collection corresponding to the requested name or ordinal.

My partial code is below:

Set cnxn = New ADODB.Connection
cnxn.Provider = "SQLOLEDB"
cnxn.Properties("Data Source").Value = "RADIANCE\PETROTEST"
cnxn.Properties("Initial Catalog").Value = "master"
cnxn.Properties("Integrated Security").Value = "SSPI"
cnxn.Open
Set cat1 = New ADOX.Catalog
Set cat1.ActiveConnection = cnxn

'Create and name the table

Set ImportTable = New ADOX.Table
With ImportTable
.Name = "zzDonors"
Set .ParentCatalog = cat1
With .Columns
.Append "Rec_Index", adInteger
.Item("Rec_Index").Properties("Identity(1,1)") = 0
.Append "Supplier", adVarWChar, 100
.Append "Terminal_Name", adVarWChar, 50
.Append "Terminal_Abbr", adVarWChar, 20
.Append "Terminal_City", adVarWChar, 50
.Append "Terminal_State", adVarWChar, 5
.Append "Product_Name", adVarWChar, 120
.Append "Brand_Type", adVarWChar, 5
.Append "Effective_Date", adDBTimeStamp
.Append "Effective_Time", adDBTimeStamp
.Append "Price", adSingle
.Append "Change", adSingle
End With
End With
'

'Append new table to Tables collection of Project
cat1.Tables.Append ImportTable


When I remove the following code the table is appended but of course the "identity" property is not set:

.Item("Rec_Index").Properties("Identity(1,1)") = 0

Please, what is the correct code to set this property?

Thanks

Gerry


 
Why not executing a CREATE TABLE instruction ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top