John Skolits
askolits at nni.com
Mon Oct 1 13:50:44 CDT 2007
Hmmm... Well I tried your code and it did not find the Caption property,
unless I had entered its value manually at some point.
The tables I'm creating are through VBA and there were never any caption
provided.
The Caption property is a strange one. It is not part of the field
properties unless you create it yourself. (Or enter the caption text using
Table Design mode.)
If you print out the properties, based on your code, the only ones found
are:
ValidationText
Required
AllowZeroLength
FieldSize
OriginalValue
VisibleValue
ColumnWidth
ColumnOrder
ColumnHidden
DecimalPlaces
DisplayControl
GUID
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
max.wanadoo at gmail.com
Sent: Monday, October 01, 2007 2:11 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Adding Caption Property
John,
You cannot do that because the property already exists! The CAPTION
property is already defined when you create a table. You cannot re-create
it.
You should be able to do something with this code below. I leave it to you
to adapt it to do whatever it is you want.
Regards
Max
Function fSetFieldCaptions()
On Error Resume Next
Dim dbs As DAO.Database, prp As Property, fld As Field, tbl As
DAO.TableDef
Set dbs = CurrentDb
For Each tbl In dbs.TableDefs
If tbl.Name = "Table1" Then
For Each fld In tbl.Fields
For Each prp In fld.Properties
If fld.Name = "Desc" Then
If prp.Name = "Caption" Then
prp.Value = "MyNewCaptionName"
End If
End If
Next prp
Next fld
End If
Next tbl
End Function
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Skolits
Sent: Monday, October 01, 2007 5:56 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Adding Caption Property
Actually tried that. Same error.
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of McGillivray, Don
[IT]
Sent: Monday, October 01, 2007 12:41 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Adding Caption Property
Shot in the dark here, but maybe you have to create the caption property for
the field BEFORE appending the field to the table.
Don
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Skolits
Sent: Monday, October 01, 2007 8:47 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Adding Caption Property
My objective is to simply add a caption to all my table fields.
I'm sure I'm missing something basic here. I went to many archives and all
the solution seemed similar, but it still won't work for me.
Can anyone tell me what's wrong?
Dim dbCurr As Dao.Database, tdf As Dao.TableDef, fld As Dao.Field Dim prop
As Dao.Property
'Create Table (This Works)
Set dbCurr = CurrentDb()
Set tdf = dbs.CreateTableDef("tbl_TEST")
'Create Field (This Works)
Set fld = tdf.CreateField("Test Field" ,dbtext, 255)
tdf.Fields.Append fld
'Create the CAPTION property. (This line is accepted)
Set prop = fld.CreateProperty("Caption", dbText, "Test Caption")
'Append the property (Breaks Here)
fld.Properties.Append prop
Error: Run-time error '3219' - Invlaid operation.
--
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
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com