retrieving the value of a user-defined table field property

G

Guest

Hi,
In my table, I have a field property 'Description', containg variable-label text. I managed to create the property, but - arrgh.. - have no luck retrieving its value! Here's a bit of code, which uses RecordSet object; I've also tried going through TableDef

Dim rs As Recordse
Set rs = db.OpenRecordset(tbName
For Each fd In rs.Field
Debug.Print fd.Description (or fd.Description.Value
Nex

Thanks a lot!
 
M

Marshall Barton

demyan said:
In my table, I have a field property 'Description', containg variable-label text. I managed to create the property, but - arrgh.. - have no luck retrieving its value! Here's a bit of code, which uses RecordSet object; I've also tried going through TableDef:

Dim rs As Recordset
Set rs = db.OpenRecordset(tbName)
For Each fd In rs.Fields
Debug.Print fd.Description (or fd.Description.Value)
Next


For the Access defined properties, you have to do two things
differently than you would with the db engine built in
properties. One, you have to explicitly use the Properties
collection, and two, use error handling to guard against a
field that does not have the property

Set db = Current Db()
On Error Resume Next
For Each fld In db.TableDefs("Holidays").Fields
Debug.Print fld .Name, fld.Properties!Description
If Err.Number > 0 Then
Debug.Print fld .Name,"No Description Supplied"
End If
Next fld
 
G

Guest

Again, thank you so much for help, Mr. Barton. The code works, although with a little quirk, printing each field name twice, the first time with the actual description, the second time with 'No description supplied' message, e.g
HOPE5 I think the things I have done in the past will help me in the futur
HOPE5 No Description Supplie
But I think I can fix that :
 
M

Marshall Barton

demyan said:
Again, thank you so much for help, Mr. Barton. The code works, although with a little quirk, printing each field name twice, the first time with the actual description, the second time with 'No description supplied' message, e.g.
HOPE5 I think the things I have done in the past will help me in the future
HOPE5 No Description Supplied
But I think I can fix that :)


That's odd, I don't see how the Debug.Print can print the
description and the If detect an error at the same time??
 

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