Connecting Tech Pros Worldwide Forums | Help | Site Map

Field Caption property

Richard
Guest
 
Posts: n/a
#1: Sep 27 '06
Hi,
I have posted this question on another site but had no luck so far. Sorry
about multiposting to those who have seen it.

I wish to add the field captions programmatically to the fields properties
when I am creating the database (VB5 DAO3.6) but caption does not appear on
the properties
list.
I'm sure it must be posible, and probable simple but I can't find out how.
Anybody know please.

Richard



Svetlana
Guest
 
Posts: n/a
#2: Sep 27 '06

re: Field Caption property


Even caption doesn't appear in the properties list i think it exists.
Just type it and see what happens.

Richard
Guest
 
Posts: n/a
#3: Sep 27 '06

re: Field Caption property



"Svetlana" <AccessMindMe@yahoo.comwrote in message
news:1159351499.454384.217950@i42g2000cwa.googlegr oups.com...
Quote:
Even caption doesn't appear in the properties list i think it exists.
Just type it and see what happens.
>
Property not found error!


RichardP via AccessMonster.com
Guest
 
Posts: n/a
#4: Sep 27 '06

re: Field Caption property


The Caption property won't be created by default, so use the CreateProperty
method of the field to manufacture a property object, then append that
property object to the fields' properties collection.

I think the caveat here is that the table has to exist in the TableDefs
collection before field properties may be appended.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200609/1

Bas Cost Budde
Guest
 
Posts: n/a
#5: Sep 27 '06

re: Field Caption property


Untested code, no error handling, adjust where you feel.

Sub makeField(cTable As String, cField As String, nType As Long,
cCaption As String, Optional nSize = 50)
'Access 97, using DAO
Dim db As Database
Dim td As TableDef
Dim fd As Field
Dim pr As Property
Set db = CurrentDb
Set td = db.TableDefs(cTable)
Set fd = td.CreateField(cField, nType, nSize)
Set pr = fd.CreateProperty("Caption", dbText)
pr.Value = cCaption
fd.Properties.Append pr
td.Fields.Append fd
End Sub


Richard schreef:
Quote:
"Svetlana" <AccessMindMe@yahoo.comwrote in message
news:1159351499.454384.217950@i42g2000cwa.googlegr oups.com...
Quote:
>Even caption doesn't appear in the properties list i think it exists.
>Just type it and see what happens.
>>
Property not found error!
>
>
--
Bas Cost Budde
Holland
Bas Cost Budde
Guest
 
Posts: n/a
#6: Sep 27 '06

re: Field Caption property


I routinely add properties to objects that are not yet collection
members. Don't think that is a problem.

You could wrap CreateProperty in a routine that first tries to set the
value of the property using dot notation, and if it fails on
PropertyNotFound makes an excursion to CreateProperty. Does that make sense?

RichardP via AccessMonster.com schreef:
Quote:
The Caption property won't be created by default, so use the CreateProperty
method of the field to manufacture a property object, then append that
property object to the fields' properties collection.
>
I think the caveat here is that the table has to exist in the TableDefs
collection before field properties may be appended.
>
--
Bas Cost Budde
Holland
Richard
Guest
 
Posts: n/a
#7: Sep 27 '06

re: Field Caption property



"Bas Cost Budde" <b.costbudde@dev.null.comwrote in message
news:efdnga$p0$3@localhost.localdomain...
Quote:
>I routinely add properties to objects that are not yet collection members.
>Don't think that is a problem.
>
You could wrap CreateProperty in a routine that first tries to set the
value of the property using dot notation, and if it fails on
PropertyNotFound makes an excursion to CreateProperty. Does that make
sense?
>
RichardP via AccessMonster.com schreef:
Quote:
>The Caption property won't be created by default, so use the
>CreateProperty
>method of the field to manufacture a property object, then append that
>property object to the fields' properties collection.
>>
>I think the caveat here is that the table has to exist in the TableDefs
>collection before field properties may be appended.
>>
>
--
Bas Cost Budde
Holland

A Big Thank You to you all.
I have it working now.
I had tried 'CreateProperty' but at the same time as creating the field
which did not work.
I now add the caption properties after all the table have been created which
works fine

Thanks
Richard


Closed Thread