Connecting Tech Pros Worldwide Forums | Help | Site Map

How to obtain field describtion with code

Uwe Range
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi there,

I am trying to write a little procedure to list all field names an
descriptions for a table. However I can't find the property which has
the description.

Can anybody help?

Thanks in advance!

Uwe

Allen Browne
Guest
 
Posts: n/a
#2: Nov 12 '05

re: How to obtain field describtion with code


If the field has a description, it is:
dbEngine(0)(0).TableDefs("MyTable").Fields.("MyFie ld").Properties("Descripti
on")

For more detail, see::
http://allenbrowne.com/func-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Uwe Range" <urange@gmx.de> wrote in message
news:641c90f5.0401050244.36b281dd@posting.google.c om...[color=blue]
>
> I am trying to write a little procedure to list all field names an
> descriptions for a table. However I can't find the property which has
> the description.[/color]


Fletcher Arnold
Guest
 
Posts: n/a
#3: Nov 12 '05

re: How to obtain field describtion with code



"Uwe Range" <urange@gmx.de> wrote in message
news:641c90f5.0401050244.36b281dd@posting.google.c om...[color=blue]
> Hi there,
>
> I am trying to write a little procedure to list all field names an
> descriptions for a table. However I can't find the property which has
> the description.
>
> Can anybody help?
>
> Thanks in advance!
>
> Uwe[/color]

Unsurprisingly, yo need to inspect the field's description property:
MyField.Properties("Description").
However, some fields might not have this property when you run your code -
so you will need some error checking like that shown below:

Private Sub cmdPrint_Click()

On Error GoTo Err_Handler

Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim strDescription As String

Set dbs = CurrentDb

For Each tdf In dbs.TableDefs
For Each fld In tdf.Fields
If UCase(Left$(tdf.Name, 4)) <> "MSYS" Then
strDescription = fld.Properties("Description")
Debug.Print """" & tdf.Name & """, """ & fld.Name & _
""", """ & strDescription & """"
End If
Next fld
Next tdf

Exit_Handler:

If Not dbs Is Nothing Then
Set dbs = Nothing
End If

Exit Sub

Err_Handler:

Select Case Err.Number

Case 3270
strDescription = ""
Resume Next

Case Else
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Select

End Sub


HTH
Fletcher


Closed Thread