473,394 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Set field description via ADOX

I can't set the field description property with the code below. I get
the error "Item cannot be found in the collection corresponding to the
requested name or ordinal". Any ideas. TIA...

Sub Test()
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim col As ADOX.Column

Set cat = New Catalog
cat.ActiveConnection = CurrentProject.Connection
Set tbl = New ADOX.Table
With tbl
.Name = g_sTable
'code to get oFlds object not shown
For Each oFld In oFlds.Rows
Set col = New ADOX.Column
col.Name = oFld("FIELDNAME")
'error occurs here
col.Properties("Description").Value = oFld("FIELDTEXT")
.Columns.Append col
Next
End With
cat.Tables.Append tbl
Set col = Nothing
Set tbl = Nothing
Set cat = Nothing
End Sub
Jun 27 '08 #1
2 3352
Hi there,

The reason your code hasn't worked is because you need to set the
parentcatalogue property of the column(s) to be the same ADOX
catalogue as the table before you can alter / add any property
definitions. Give this a try:

Sub Test()

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

Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
Set tbl = New ADOX.Table

With tbl
.Name = g_sTable

'code to get oFlds object not shown

For Each oFld In oFlds.Rows
.columns.append "Insert Name of Column Here", columntype
here
with tbl.columns("Insert Name of Column Here")
set .ParentCatalog = cat
.Properties("Description") = "This is a test"
.Properties("Autoincrement") = true
' and just keep adding the bits you need
end with
Next
End With

cat.Tables.Append tbl

'cleanup
set tbl = nothing
set cat = nothing

end sub

I just 'aircoded' this and havent had a chance to test the actual code
out so please check it for typo's. Basically you can see how the
properties are added once the .ParentCatalog is set for the column.
Once that is done you should'nt have any troubles.

Cheers

The Frog
Jun 27 '08 #2
Wow! I just needed 1 line of code to set the column ParentCatalog
like you said. Thanks...
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: hytga | last post by:
hi can n e 1 tell me if there's a way to get the column properties from a table? properties like caption, description etc thank you
2
by: Tom Loach | last post by:
After reviewing the messages on google and using the Access 2000 developers handbook I came up with the following code to add a field to an access table. I'm working in Access 2002, and the code...
1
by: GGerard | last post by:
Hello I am working with Access 2000 I have two tables joined on a one to many relationship between two fields: Table1:FieldID (one) is joined to Table2:FieldMyID (many) Field Properties...
2
by: gaffar | last post by:
Hello Sir, How to assign more than one primary key to table by this below following code. i am able assign to a single field only. how to assign primary key to more than one field. the primary key...
1
by: Hexman | last post by:
I'm creating a new Access table using ADOX. I can add columns and indexes, but I'm baffled on how to change field properties. Can someone give me a hand? Want to change properties such as:...
3
by: Miro | last post by:
Something weird I have run into when trying to add a boolean field to an Access table by code. -Just wondering if anyone else has run into this. ( vb.net 2005 express ) If I add any other...
17
by: The Frog | last post by:
Hello everyone, I am working on an application that can build database objects in MS Access from text files. I suppose you could call it a backup and restore type routine. Accessing the...
2
by: balaki | last post by:
Hi All, I am using VB.Net 2003 and Ms-Access 2003. I want to change the data type of fileds programmatically. I could not find any method in vb.net to do this. i) I tried using the sql query...
3
by: Iain King | last post by:
I'm manipulating an MS Access db via ADODB with win32com.client. I want to rename a field within a table, but I don't know how to. I assume there is a line of SQL which will do it, but nothing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.