Solved

Got Focus/Lost Focus Procedure

Posted on 1998-09-10
7
503 Views
Last Modified: 2010-05-18
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)
0
Comment
Question by:matthewkwp
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Expert Comment

by:bharris1
ID: 1434088
What EXACTLY are you looking for?  Explain in detail.
0
 

Author Comment

by:matthewkwp
ID: 1434089
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.
0
 
LVL 1

Accepted Solution

by:
bharris1 earned 100 total points
ID: 1434090
In a module:
Public Sub SetBold(txtBox as TextBox)
    txtBox.FontBold = True
End Sub

Public Sub SetNormal(txtBox as TextBox)
    txtBox.FontBold = False
End Sub


In each GotFocus/LostFocus event:

Private Sub Text1_GotFocus()
    SetBold Text1
End Sub

Private Sub Text1_LostFocus()
    SetNormal Text1
End Sub

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:dapperry
ID: 1434091
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=false
End Sub

Private Sub Text1_GotFocus(Index As Integer)
          Text1(Index).Font.Bold=true
End Sub

Let me know if you have any questions.

:) D Perry
0
 
LVL 1

Expert Comment

by:bharris1
ID: 1434092
This would work great if the TextBoxes were in a control array.

0
 

Author Comment

by:matthewkwp
ID: 1434093
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
0
 
LVL 3

Expert Comment

by:dapperry
ID: 1434094
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=false
End Sub

Private Sub Text1_GotFocus(Index As Integer)
          Text1(Index).Font.Bold=true
End Sub

Let me know if you have any questions.

:) D Perry
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now