What is controltip text? Looking for a field to store some text

R

Robert

I need a field in the properties to store a descriptive name of a textbox's
contents.

If a required field, which has "R" in the Tag field in the properties, has
not been entered a message box appears:

MsgBox "Please enter a value for " & ctl.Name

Where ctl.Name is the name of the text box. l need to be able to say, for
example, "Department Number" instead of "txtDeptno". I could put
"Department Number" after the "R" in the tag and parse up tag but is there
another field? How about ControlTip Text or Validation Text? (I can't find
a simple definition of these fields in the Help. (Indeed, I was wondering
what a Validation Rule is anyway, but how do you look that up with that
help?).

Is there any way to reference the label field attached to the textbox?

I am using Access 2002.

This is the complete code if you're interested:

For Each ctl In Me.Controls
If ctl.Tag = "R" Then
If LenB(Nz(ctl, vbNullString)) = 0 Then
MsgBox "Please enter a value for " & ctl.Name
Cancel = True
ctl.SetFocus
Exit Sub
End If
End If
Next ct
 
A

Allen Browne

ControlTipText is the message Access should display when the user pauses the
mouse over the control. You often see this kind of thing over toolbar
buttons.

ValidationText it the message Access should display if the ValidationRule is
not met.

The simplest solution might be to use a delimited list in the Tag property.
Use Split() to parse it into an array, and treat the array elements as
either special by position (e.g. "R;DepartmentNumber") or named arguments
(e.g. "IsRequired=True;DisplayName=Department Number")

If the control has an attached label, that's what the user knows it by. You
could read the label as:
Me.txtDepartno.Contols(0).Caption

It might be possible to read the Required property directlly instead of
using the Tag property:
Dim strField As String
strField = Me.txtDeptNo.ControlSource
Me.Recordset.Fields(strField).Required
Obviously needs a bit more than that to cope with unbound controls, those
bound to an expression, or those bound to a calculated query field (lacks
the SourceTable property.)
 
D

David W. Fenton

I need a field in the properties to store a descriptive name of a
textbox's contents.

If a required field, which has "R" in the Tag field in the
properties, has not been entered a message box appears:

MsgBox "Please enter a value for " & ctl.Name

Have you considered the Status Bar text property? What you place
there appears in the status bar, and could be used to drive a prompt
to the user.
 
R

Robert

Thanks. The attached label already has what I want in it. But since I am
specifying the control variably how could I reference the attached label?

For Each ctl In Me.Controls
..
..
..
Next ctl
 
R

Robert

It appears to be taking text from the table definition. It would involve
going through all the tables and tweaking the field descriptions a little
bit but it could work. Thanks.
 
D

David W. Fenton

It appears to be taking text from the table definition. It would
involve going through all the tables and tweaking the field
descriptions a little bit but it could work.

You can change to anything you want in the control properties and
don't need to worry about what's in the field's description in the
table itself.
 
A

Allen Browne

Needs error handling to handle controls that don't have an attached label:

Dim ctl As Control
For Each ctl In Me.Controls
ctl.Controls(0).Caption
Next
 
R

Robert

Thank you.
Allen Browne said:
Needs error handling to handle controls that don't have an attached label:

Dim ctl As Control
For Each ctl In Me.Controls
ctl.Controls(0).Caption
Next
 

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