Highlight Current Text Field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When adding information on a student, the educator(s) have a difficult time
seeing the cursor. How can I highlight the entire text field without
entering any data (where the cursor currently resides). I used a default of
spaces(blanks) but it is messing up the queries and reports if they do not
clear out the field.

Thanks in advance

Len
 
The easiest way to do this is to use conditional formatting for each field
and in the first drop-down, select "Field has focus". Then change the
color, bold, italics, etc.


Rick B
 
Hi, Len.

Use the OnGotFocus and OnLostFocus events to toggle the control's backcolor:

Private Sub Business_GotFocus()
'Yellow
Call ChangeBackColor(65535)
End Sub

Private Sub Business_LostFocus()
'White
Call ChangeBackColor(16777215)
End Sub

Private Sub ChangeBackColor(intColor As Long)
ActiveControl.BackColor = intColor
End Sub

Hope that helps.
Sprinks
 
One solution is to program the GotFocus/LostFocus events to set the
BackColor property to something like green or red.

Paste this into a standard module so you can call it from any form:

Sub Highlight(TheForm, TheControl)
Forms(TheForm).Controls(TheControl).BackColor = vbGreen
End Sub
Sub UnHighlight(TheForm, TheControl)
Forms(TheForm).Controls(TheControl).BackColor = vbWhite
End Sub

Then, for each control you want to highlight, paste the following to the
GotFocus event ("text0" is actually the name of the control):
Call Highlight(Me.Name, "text0")

For the LostFocus event, paste:
Call UnHighlight(Me.Name, "text0")
 
If this can be called from any form, what do you put in the module coding for
TheFrom and TheControl? I would think the specific name of my form and
control but that makes it specific and contradicts using it for any form.

Kristine
 
You leave the module coding the way it is (although the code would be better
written as:

Sub Highlight(TheForm As String, TheControl As String)
Forms(TheForm).Controls(TheControl).BackColor = vbGreen
End Sub
Sub UnHighlight(TheForm As String, TheControl As String)
Forms(TheForm).Controls(TheControl).BackColor = vbWhite
End Sub
)

When you want to use that code, you call it like:

Call Highlight("MyFormName", "MyControlName")

where you replace MyFormName and MyControlName with whatever's appropriate.
 
Back
Top