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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HIghlight the current controls label 1

Status
Not open for further replies.

Cleis

Technical User
Jun 4, 2000
197
US
Hi Group:

I'd like to highlight the current controls label on the got focus event without putting code into each controls got focus event. Any ideas?? I'm currently using the following for the data input fields but I don't think this logic will apply to labels

Dim ctl2 As Control
For Each ctl2 In Me.Controls
Select Case ctl2.ControlType
Case acComboBox, acTextBox
If (ctl2.Tag = 1) Then

ctl2.Enabled = False
ctl2.BackColor = 16777215
ctl2.Locked = True
ctl2.SpecialEffect = 0
ctl2.TabStop = True

End If
End Select
Next ctl2
 
How are ya Cleis . . . . .

[blue]Labels[/blue] also have the [blue]Tag[/blue] property!

Calvin.gif
See Ya! . . . . . .
 
Hey Aceman!!

LOL!!! Ya' know, I never thought. . . (I guess that's my 1st problem!! Thanks for the insight! Now I know what to do!! Here is an easy star for ya!


Kind Regards!


 
How about this. Build yourself a class module. clsHighlight.
1)In clsHighlight define private variables with events
Example:
private withEvents mControl as access.control
2) in the set property define an event procedure for on focus

Public Property Set HighlightControl(theControl As Access.control)
Set mControl = theControl
mControl.onGotFocus = "[Event Procedure]"
End Property
3) Sink the event

private sub mControl_GotFocus()
dim lblControlLabel as access.control
set lblControlLabel = mControl.controls(1)
...do all your higlighting here
end sub

4) Loop through all your controls on the form that have a label associated to them and instantiate them as a clsHighlight.

When any of these controls get the focus their label will highlight.

Write a class module once, use it everywhere.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top