Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
403 views
in Technique[技术] by (71.8m points)

sql - MS Access: setting table column Caption or Description in DDL?

Is it possible to set a table column's Caption or Description properties in MS Access using DDL? Ideally, we could include them in a CREATE TABLE statement.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use DAO to set Caption and Description properties as Andrea suggested. Just be aware that both Caption and Description are user-defined, not default properties ... meaning that they don't exist before you assign them a value.

For example the following statement triggers error 3270, 'Property not found', because I have not assigned a Description for the id field:

Debug.Print CurrentDb.TableDefs("tblFoo").Fields("id").Properties("Description")

In order to assign a Description value for the field, I would first have to CreateProperty for "Description" then Append the new property to the field's Properties collection. Rather than write code to show you, I will suggest you use Allen Browne's SetPropertyDAO function. That function will handle the details for you. Be sure to grab the HasProperty function, too, because it is called by SetPropertyDAO. (The code for HasProperty is on the same web page, immediately below the SetPropertyDAO function code.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...