I would use a TableDef object for this, rather than a Recordset. I didn't
even know you could modify an existing Caption property using a recordset,
but it still makes mnore sense to do it with a TableDef.
Further, there's a note in the help topic for the CreateProperty method:
"You can create a user-defined Property object only in the Properties
collection of an object that is *persistent*." The word "persistent" is a
in the help text links to this definition: "An object stored in the
database; for example, a database table or QueryDef object. Dynaset-type or
snapshot-type Recordset objects are not considered persistent objects
because they are created in memory as needed."
Now, although it refers to dynaset and snapshot-type recordsets, I've tried
it using a table-type recordset ('Set rs =
CurrentDb.OpenRecordset("tblMyTable", dbOpenTable)'), and it still wouldn't
let me append the property.
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)
"David G." wrote in message
news:(E-Mail Removed)...
I want to assign English/Readable captions to all fields in any table.
If I manually add a caption to a field, I can edit the property later
in VBA. If the caption has never been set, I can't seem to be able to
add a Caption property to any field.
--code snippet
dim rs as DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Select * FROM tblMyTable")
For i = 0 To rs.Fields.Count - 1
rs.Fields(i).Properties.Append & _
rs.Fields(i).CreateProperty("Caption", & _
dbText, fBuildCaption(rs.Fields(i).Name))
next i
--end code
I get "Invalid Operation. 3219" error message.
THANKS!
David G.