[AccessD] Setting the Caption property for a table field

John Skolits JSkolits at CorporateDataDesign.com
Mon Feb 10 21:14:00 CST 2003


"Caption property is not created automatically with the field"

Yep. that's it. Never knew that.

It's interesting that if you add the caption in the table's design view, the
Caption property may only be retrieved by it's constant ("caption") not by
it's ordinal position. I guess that makes sense but I would have thought it
would have added it as the next indexed item.

Thanks!

John

-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com]On Behalf Of Brett Barabash
Sent: Monday, February 10, 2003 2:37 PM
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] Setting the Caption property for a table field


I am totally going off the top of my head here, but...

As Chris said, a Caption property is not created automatically with the
field.  It needs to be created and appended to the field's properties
collection.  Code to do this looks something like:

Dim db As DAO.Database
Dim fld As DAO.Field
Dim prp As DAO.Property

Set db = CurrentDB()
Set fld = db.TableDefs("tblMyTable").Fields("CustomerName")

Set prp = fld.CreateProperty("Caption")
prp.Value = "Customer Name"
fld.Properties.Append prp
fld.Properties.Refresh

Set prp = Nothing
Set fld = Nothing
Set db = Nothing

Of course, in the real world you would also have to handle a situation where
someone has already defined a Caption.


-----Original Message-----
From: Chris Mackin [mailto:chris at denverdb.com]
Sent: Monday, February 10, 2003 1:21 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Setting the Caption property for a table field


The key is that the Caption property doesn't exist until it's created, so
you can't just set the property, create it first.

Chris Mackin
Denver Database Consulting, LLC
www.denverdb.com


-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com]On Behalf Of John Skolits
Sent: Monday, February 10, 2003 12:05 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] Setting the Caption property for a table field


Anyone know how to set the "Caption" property of a table field in code?

I'm thinking this is a dumb question but maybe it's not.

John Skolits


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list