(Q) Some of the records in my database have values that are longer
than the width of the bound control on the form. Is there a way I can display the
complete text without requiring the user to click in the field and using arrow keys to
read the value?
(A) Access Form controls have a property called ControlTipText (what
you see in the yellow tooltip popup if you place the mouse over a control for some time).
This property can be easily used to display the complete value of the actual
control itself.
Note that this method will not work for
continuous forms since changing a control's property in continuous mode affects all
records being displayed.
Also note that sShowToolTip will work for
comboboxes as well. Given the assumption that most combos have two columns, a bound ID
column and a display column, the sub will update the display with the unbound column's
value. I've set the condition for columnCount=2 because if you have more than 2 columns,
it's tricky determining which column's value you want to display in the combobox.
Paste this sub in a new module.
Public Sub sShowToolTip(frm As Form)
Dim ctl As Control, i As Integer
On Error Resume Next
For Each ctl In frm.Controls
With ctl
If .ControlType = acTextBox Then
.ControlTipText = .value
ElseIf .ControlType = acComboBox Then
If .ColumnCount = 2 And .value <> "" Then
.ControlTipText = .Column(.BoundColumn)
End If
End If
End With
Next ctl
Set ctl = Nothing: Set frm = Nothing
End Sub
Now from the Current event of the form, call this sub as
Private Sub Form_Current()
Call sShowToolTip(me)
End Sub
If you need to update the ToolTip when the contents of a textbox changes as well,
simply call the sub again from the AfterUpdate event of the control.
Private Sub SomeTextBox_AfterUpdate()
Call sShowToolTip(me)
End Sub
|