Setting Table Field Descriptions

G

Guest

How can one automatically set the field descriptions of a table in an Access
2003 .mdb database?

Simple enough question, right?
 
D

Douglas J. Steele

While the table's open in Design view, you type the descriptions in the
Description column beside each field.

DId you have something else in mind?
 
G

Guest

Yes, I wish to set the description in code. The vba code I have does some
magic and creates a table for me, but then I want to add in the field
descriptions.

Now, I know that if I can change a description if one exists by using:

CurrentDB.TableDefs![MyTable].Fields![MyField].Properties!Description =
MyDescription

The trouble is that I just created the table as part of the vba code, and
thus I don't have any field descriptions included yet. Apparently, trying
this code won't work because there is, a priori, no "Description" property to
change. (This concept is a bit strange to me, BTW)

Thanks!
 
D

Douglas J. Steele

Take a look at the CreateProperty method in the Help file.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Rob said:
Yes, I wish to set the description in code. The vba code I have does some
magic and creates a table for me, but then I want to add in the field
descriptions.

Now, I know that if I can change a description if one exists by using:

CurrentDB.TableDefs![MyTable].Fields![MyField].Properties!Description =
MyDescription

The trouble is that I just created the table as part of the vba code, and
thus I don't have any field descriptions included yet. Apparently,
trying
this code won't work because there is, a priori, no "Description" property
to
change. (This concept is a bit strange to me, BTW)

Thanks!

Douglas J. Steele said:
While the table's open in Design view, you type the descriptions in the
Description column beside each field.

DId you have something else in mind?
 
T

Tony Toews [MVP]

Rob said:
The trouble is that I just created the table as part of the vba code, and
thus I don't have any field descriptions included yet. Apparently, trying
this code won't work because there is, a priori, no "Description" property to
change. (This concept is a bit strange to me, BTW)

Dim prp as property
Set prp = tdfField.CreateProperty("Caption", dbText, "Unit #")
tdfField.Properties.Append prp

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top