Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight cursor position on a form? 1

Status
Not open for further replies.

easydusit

Programmer
Nov 19, 2000
5
US
Is there a way to highlight the cursor position, on a form
in access 97?
Also is it possible to better highlight a command button?
The thin line box access uses is hard for my client to see!
Any help is surly appreciated

This is a great place for us beginners :)
 
Both these things are very easy to achieve.

You need to use the GotFocus and LostFocus events.

Examples:

Eamample 1 A text box called txtName

Private Sub txtName_GotFocus()
txtName.BackColor = 10092543

End Sub

Private Sub txtName_LostFocus()
txtName.BackColor = 16777215

End Sub

When the text box has the focus ( i.e. the cursor is in there ) then the back colour will be a pale yellow.


Eamample 2 A command button called cmdAdd

Private Sub cmdAdd_GotFocus()
cmdAdd.FontBold=True

End Sub

Private Sub cmdAdd_LostFocus()
cmdAdd.FontBold=False

End Sub

When the command button has the focus then the font will be bolded.




Bill Paton
william.paton@ubsw.com
Check out my website !
 
Place the following function call in both the ON GOT FOCUS and ON MOUSE MOVE events of the buttons or text boxes that you want to highlight. The ON MOUSE MOVE event responds to moving the mouse over the control and ON GOT FOCUS handles using the keyboard to navigate.

=MouseOver("OptionLabel1","Option1")

Place these two functions in the CLASS MODULE of the form that contains the controls.

Sub ChangeMe()
Dim frmControl As Control, i As Integer, sName As String

For Each frmControl In Me.Controls
For i = 1 To conNumButtons
sName = "OptionLabel" & LTrim(str(i))
If frmControl.Name = sName Then
frmControl.ForeColor = 0
End If
Next
Next

End Sub

Private Function MouseOver(sLabel As String, sControl As String)

Call ChangeMe
Me(sLabel).ForeColor = 128
Me(sControl).SetFocus

End Function

Enjoy,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top