How read or write the Caption of table fields?

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"...
 
A

Allen Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top