I figured this out the other day when I was fiddling. This code will change the font name, font size, font font weight, and color so that the user can clearly see which button is selected when tabbing through buttons on a form. I also used it in text boxes to bold the text when the text box has focus. It worked there as well. I have not tried it with any other controls on forms yet.
This code is in a separate module called GenModule
Public Sub SetFont(strFontName As String, strFontSize As String, intFontWeight As Integer, lngFontColor As Long, conFontControl As Control)
conFontControl.FontName = strFontName
conFontControl.FontWeight = intFontWeight
conFontControl.FontSize = strFontSize
conFontControl.ForeColor = lngFontColor
End Sub
Just call the program using the below code. One for the GotFocus and one for the LostFocus
Private Sub yourSubHere_GotFocus()
' "Font Name", "Font Size", "Font Weight", "Font Color", Control
GenModule.SetFont "Tahoma", "10", 600, 16711680, Me.yourControlHere
End Sub
Private Sub yourSubHere_LostFocus()
' "Font Name", "Font Size", "Font Weight", "Font Color", Control
GenModule.SetFont "Tahoma", "8", 400, -2147483630, Me.yourControlHere
End Sub
Happy programming!
MistyWolf
This code is in a separate module called GenModule
Public Sub SetFont(strFontName As String, strFontSize As String, intFontWeight As Integer, lngFontColor As Long, conFontControl As Control)
conFontControl.FontName = strFontName
conFontControl.FontWeight = intFontWeight
conFontControl.FontSize = strFontSize
conFontControl.ForeColor = lngFontColor
End Sub
Just call the program using the below code. One for the GotFocus and one for the LostFocus
Private Sub yourSubHere_GotFocus()
' "Font Name", "Font Size", "Font Weight", "Font Color", Control
GenModule.SetFont "Tahoma", "10", 600, 16711680, Me.yourControlHere
End Sub
Private Sub yourSubHere_LostFocus()
' "Font Name", "Font Size", "Font Weight", "Font Color", Control
GenModule.SetFont "Tahoma", "8", 400, -2147483630, Me.yourControlHere
End Sub
Happy programming!
MistyWolf