How read or write the Caption of table fields?

  • Thread starter Thread starter Fjordur
  • Start date Start date
F

Fjordur

Hi,
I can't seem to find how to read / modify the Caption property of table
fields from VB. Can it be done? How?
For Each Fld In Tble.Fields
Debug.Print Fld.Caption
Next Fld
gives me "Method or data member not found"...
 
Several of these properties do not exist if you have nothing in the
property. That's true for the Description of the field, and other properties
too.

You can use a function with error handler to see if the property exists:

Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant

On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function

Or you can just use error handling in your code to recover from the error.
This example illustrates how to do that with the field Descriptions:
http://allenbrowne.com/func-06.html
 
Back
Top