473,809 Members | 2,780 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ActiveConne ction = 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.Appe nd tbl
Set col = Nothing
Set tbl = Nothing
Set cat = Nothing
End Sub
Jun 27 '08 #1
2 3389
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.ActiveConne ction = 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("In sert Name of Column Here")
set .ParentCatalog = cat
.Properties("De scription") = "This is a test"
.Properties("Au toincrement") = true
' and just keep adding the bits you need
end with
Next
End With

cat.Tables.Appe nd 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
2562
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
1953
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 below steps through without a glich. Problem is it doesn't add the column to the table. Any help appreciated: Thanks, Tom
1
1950
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 setting: FieldID : Field Size - Long Integer New Values - Increment
2
1421
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 assigning code line is symboled kept with in the *************** in the below code. 'Creating database Dim cat As Catalog = New Catalog
1
11601
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: Description (Column property?), Decimal Places, Caption, Default value, Required indicator, Format, etc.... TIA,
3
3570
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 field other than boolean the "command" version of adding a field works great. But if I try to add a boolean field, I get an exception error when its trying to be added, so instead I have to use the function meathod. -Code is below.
17
4039
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 fields, tables, relationships, and indexes is no issue for me via DAO code. The issue I have is that I am not sure which properties are actually necessary / available to set from code for each possible type of field. I have looked fo´r a reference on...
2
2929
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 "ALTER TABLE TableName ALTER COLUMN FieldName Number" It works for data type like 'Number', 'Memo' etc. But if I want to change to 'Long Integer' (sub type of Number), it does not work. ii) I tried using ADOX as shown below. It shows the 'Operation...
3
2715
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 I've tried (from searching) has worked. Basic code: import win32com.client connection = win32com.client.Dispatch(r'ADODB.Connection') DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=dbfile.mdb;' connection.Open(DSN)
0
10640
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10387
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.