matthewkwp
asked on
Got Focus/Lost Focus Procedure
A procedure that uses "Got Focus" and "Lost Focus". It needs to get the "Property Name" and use that name as a variable to set the Font.Name=True (False on the Lost Focus)
What EXACTLY are you looking for? Explain in detail.
ASKER
I have a form with 12 text boxes on it. When a person moves from one text box to another I want the font to change to Bold. Like wise when the focus is lost, the font will go back to normal. I want to do a procedure, not having to code each text box. The idea is to treat the property name as a variable and change the font according to text.box name.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BHarris1's answer (He beat me to the 'Submit' button) insists on you putting a lot of code. Try my answer instead:
Instead of using the property name (which I don't think you can do) why don't you create a control array of text boxes. Then there is a single got focus, and a single lost focus event. You can then determine which box is losing or getting the focus, by getting the value of index.
Code would look like this.
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).Font.Bold=fal se
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).Font.Bold=tru e
End Sub
Let me know if you have any questions.
:) D Perry
Instead of using the property name (which I don't think you can do) why don't you create a control array of text boxes. Then there is a single got focus, and a single lost focus event. You can then determine which box is losing or getting the focus, by getting the value of index.
Code would look like this.
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).Font.Bold=fal
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).Font.Bold=tru
End Sub
Let me know if you have any questions.
:) D Perry
This would work great if the TextBoxes were in a control array.
ASKER
Thank you both for your help. At my level (or lack there of) bharris's works for me. Sorry D Perry >:(, when you start getting into arrays it is beyond me at this point. Thanks D Perry for your time
BHarris1's answer (He beat me to the 'Submit' button) insists on you putting a lot of code. Try my answer instead:
Instead of using the property name (which I don't think you can do) why don't you create a control array of text boxes. Then there is a single got focus, and a single lost focus event. You can then determine which box is losing or getting the focus, by getting the value of index.
Code would look like this.
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).Font.Bold=fal se
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).Font.Bold=tru e
End Sub
Let me know if you have any questions.
:) D Perry
Instead of using the property name (which I don't think you can do) why don't you create a control array of text boxes. Then there is a single got focus, and a single lost focus event. You can then determine which box is losing or getting the focus, by getting the value of index.
Code would look like this.
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).Font.Bold=fal
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).Font.Bold=tru
End Sub
Let me know if you have any questions.
:) D Perry