> I'm using the following code to try to change a caption property for a
> field in a table.
[quoted text clipped - 9 lines]
> I'm using Access 2002.
> Any ideas welcome.
This function first tries to set an already existing property, and if an
error 3270 (property not found) occurs, it appends the new property to the
collection. Paste it into a standard module:
''' BEGIN CODE '''
Sub SetObjProperty(pObject As Object, pProperty As String, pType As Integer,
pValue As Variant)
Const PROPERTY_NOT_FOUND As Long = 3270
Dim prp As Property
'
On Error GoTo SetObjProperty_Err
'
pObject.Properties(pProperty) = pValue
pObject.Properties.Refresh
SetObjProperty_Exit:
Set prp = Nothing
Exit Sub
SetObjProperty_Err:
If Err.Number = PROPERTY_NOT_FOUND Then
With pObject
Set prp = .CreateProperty(pProperty, pType, pValue)
.Properties.Append prp
.Properties.Refresh
End With
Resume SetObjProperty_Exit
Else
MsgBox Err.Number & ": " & Err.Description, vbCritical,
"SetObjProperty"
Resume SetObjProperty_Exit
End If
End Sub
''' END CODE '''
Use it like this:
SetObjProperty fld, "Caption", dbText, strCaption
Bob Darlington - 30 Oct 2007 06:32 GMT
Thanks Stuart,
Sorry about the delay getting back to you.

Signature
Bob Darlington
Brisbane
>> I'm using the following code to try to change a caption property for a
>> field in a table.
[quoted text clipped - 49 lines]
>
> SetObjProperty fld, "Caption", dbText, strCaption
> I'm using the following code to try to change a caption property for a
> field in a table.
[quoted text clipped - 9 lines]
> I'm using Access 2002.
> Any ideas welcome.
Hi Bob.
Just a shot in the dark but wouldn't the property you're trying to create
already exist? Shouldn't you be trying to set its value rather than create
it?
Keith.
www.keithwilby.com
Bob Darlington - 30 Oct 2007 06:33 GMT
Thanks Keith,
That was it (see Stuart's reply).
Sorry about the delay getting back to you.

Signature
Bob Darlington
Brisbane
>> I'm using the following code to try to change a caption property for a
>> field in a table.
[quoted text clipped - 18 lines]
> Keith.
> www.keithwilby.com