Your original post states "I know some of the fields contain descriptions
and captions". Yes, you'll get an error on those fields that don't contain
descriptions.
What you can do is set your error handling to ignore the error:
On Error GoTo EH
Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim fldCurr As DAO.Field
Dim prpCurr As DAO.Property
Dim varDescription As Variant
Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
Debug.Print "Fields in Table " & tdfCurr.Name & ":"
For Each fldCurr In tdfCurr.Fields
strDescription = fldCurr.Properties("Description")
Debug.Print " " & fldCurr.Name & (" (" + varDescription & ")")
Next fldCurr
Next tdfCurr
EndIt:
Set prpCurr = Nothing
Set fldCurr = Nothing
Set tdfCurr = Nothing
Set dbCurr = Nothing
Exit Sub
EH:
Select Case Err.Number
Case 3270 ' Property Not Found
varDescription = Null
Resume Next
Case Else
MsgBox Err.Number & ": " & Err.Description
Resume EndIt
End Select
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Dale Fye" <(E-Mail Removed)> wrote in message
news:O3oAWz$(E-Mail Removed)...
> But if I set the property, won't that overwrite whatever is already in
> that property?
>
> I'm confused.
>
> "David H" <(E-Mail Removed)> wrote in message
> news:7E8ACA3D-6775-4590-83C8-(E-Mail Removed)...
>> If I recall correctly, YES the property has to be set otherwise you'll
>> get an
>> error. You can either trap the error if you're referencing the property
>> by
>> name or you could loop through the properties collection of the field and
>> check for the property name.
>>
>>
>>
>> "Dale Fye" wrote:
>>
>>> I'm trying to read a fields caption and description via VBA.
>>>
>>> When I iterate through the fields of a table that I know some of the
>>> fields
>>> contain descriptions and captions, refering to the property always
>>> returns
>>> an error (3270, Property not found).
>>>
>>> Do I have to set the property before I can refer to it, even if there is
>>> already text in the property, as seen in the table design view? Or am I
>>> missing something?
>>>
>>> Dale
>>>
>>>
>>>
>>>
>>>
>
>