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

finding which control is active

Status
Not open for further replies.

Nickaroo

MIS
Mar 24, 2003
21
US
Hi,

I want to know which control is active on the current form regardless of control.....

I have started some code, but don't seem to have the hang of it..Help

With ctl
Select Case .ctl
Case acComboBox
Response = MsgBox("Combo Box", vbInformation, "TYPE")

Case acTextBox
Response = MsgBox("Text Box", vbInformation, "TYPE")
End Select
End With


Thanks

Nick
 
you can use me.activecontrol to figure out which control has focus. what exactly are you trying to accomplish? You can reference me.activecontrol and then use any of its properties or methods, so if the activecontrol is a list/combobox you could say me.activecontrol.listindex and it would return the listindex for that control. Tell me what else you might need to know...
 
I want to know what type of control is active when is recieves focus?
 
well you already know what control is active when it receives focus. If you place code in the gotfocus event of any control that code won't fire until that control becomes the activecontrol on the form. Perhaps a more detailed explanation would help. Sorry for my lack of understanding.
 
Hi!

Perhaps something like this:

[tt]dim ctl as control
set ctl=me.activecontrol
with ctl
select case .controltype
case aclabel
' ...
case actextbox
' ...
case accombobox
' ...
...
case else
' ...
end select
end with
set ctl=nothing[/tt]

There's a nice xample in F1 on ControlType Property

HTH Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top