Display Field Description in a Text Box

D

DaveH

Hello

I would like to have a text box on my form that displays the field
description (entered in table design view) for the currently selected bound
control. I know it is already displayed in the status bar, but I would like
it in a text box too!

Any ideas?

Many thanks

Dave
 
A

Allen Browne

The simplest approach would be to read it from the StatusBarText property of
the control on your form.

For example, if you have a text box named FirstName, with the appropriate
explanation in its Status Bar Text property, you could put another text box
on the form and set its Control Source to:
=[FirstName].[StatusBarText]

If you do want to read the Description property of the field in the table,
you can do that as:
=Currentdb.TableDefs("Table1").Fields("FirstName").Properties("Description")
However, that expression will error if the field has no description, so you
really have to use a custom function to retrieve the property and recover
gracefully if it errors. Here's an example of doing that:
http://allenbrowne.com/func-06.html
 
J

Jeff Boyce

Dave

Are you saying that you wish to take up (valuable) screen space repeating
what is already showing in the status bar?

Here's an alternative -- put the text that you display in the status bar
into a ToolTip. That way, when a user hovers his/her cursor over the
control, the "description" pops up on screen but doesn't stay there, taking
up room.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
D

Dirk Goldgar

Allen Browne said:
The simplest approach would be to read it from the StatusBarText property
of the control on your form.

For example, if you have a text box named FirstName, with the appropriate
explanation in its Status Bar Text property, you could put another text
box on the form and set its Control Source to:
=[FirstName].[StatusBarText]

If you do want to read the Description property of the field in the table,
you can do that as:

=Currentdb.TableDefs("Table1").Fields("FirstName").Properties("Description")

You could get the description directly from the field in the form's
recordset, which would be more efficient:

=Recordset.Fields("FirstName").Properties("Description")

As you cautioned, you still have to deal with the error if the property
doesn't exist. This might work, cumbersome though it is.

=IIf(IsError(Recordset.Fields("FirstName").Properties("Description")),
Null,
Recordset.Fields("FirstName").Properties("Description"))

But a custom function is probably better.
 
D

DaveH

Thats great,

Many thanks for your help!



Dirk Goldgar said:
Allen Browne said:
The simplest approach would be to read it from the StatusBarText property
of the control on your form.

For example, if you have a text box named FirstName, with the appropriate
explanation in its Status Bar Text property, you could put another text
box on the form and set its Control Source to:
=[FirstName].[StatusBarText]

If you do want to read the Description property of the field in the table,
you can do that as:

=Currentdb.TableDefs("Table1").Fields("FirstName").Properties("Description")

You could get the description directly from the field in the form's
recordset, which would be more efficient:

=Recordset.Fields("FirstName").Properties("Description")

As you cautioned, you still have to deal with the error if the property
doesn't exist. This might work, cumbersome though it is.

=IIf(IsError(Recordset.Fields("FirstName").Properties("Description")),
Null,
Recordset.Fields("FirstName").Properties("Description"))

But a custom function is probably better.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

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