Change Field Caption

D

DennisGuilbault

I want to put some code together to make my field captions in all of my
tables set to the field description.

I know how to get the field description --> fld.properties("Description")

I can't for the life of me figure out how to get or set the field caption.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RGVubmlzR3VpbGJhdWx0?=,
I want to put some code together to make my field captions in all of my
tables set to the field description.

I know how to get the field description --> fld.properties("Description")

I can't for the life of me figure out how to get or set the field caption.
In what application environment? And which version of the application?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
D

DennisGuilbault

Access XP

Cindy M -WordMVP- said:
Hi =?Utf-8?B?RGVubmlzR3VpbGJhdWx0?=,

In what application environment? And which version of the application?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)


This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
D

DennisGuilbault

Never mind. I finally figured it out. See below:

Public Function fnChangeCaption()
Dim dbs As Database
Dim tdf As TableDef
Dim fld As Field
Dim prp As Property

On Error GoTo ErrHandler

Set dbs = CurrentDb

Set tdf = dbs.TableDefs("tblPosting")

For Each fld In tdf.Fields
Set prp = fld.CreateProperty("Caption", dbText,
fld.Properties("Description"))
fld.Properties.Append prp
Next

ExitThisFunction:

Set dbs = Nothing

ErrHandler:

MsgBox Err.Number & vbNewLine & _
Err.Description, vbOKOnly + vbCritical, "Error!"

Err.Clear

GoTo ExitThisFunction

End Function
 
Top