Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default userform1.activecontrol.name

Msgbox Userform1.ActiveControl.name

Does or should this work with controls on a multipage form? When I use it,
all I get is "frame1". No matter which control is selected


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default userform1.activecontrol.name

If the control is contained within a frame control the Frame will be
the active control, which will in turn have its own ActiveControl.
This code should resolve in the active control nested within frames:

Dim Ctrl As MSForms.Control
Set Ctrl = Me.ActiveControl
Do Until Not TypeOf Ctrl Is MSForms.Frame
Set Ctrl = Ctrl.ActiveControl
Loop
MsgBox "Active control = " & Ctrl.Name


"Italian Job" wrote in message ...
Msgbox Userform1.ActiveControl.name

Does or should this work with controls on a multipage form? When I use it,
all I get is "frame1". No matter which control is selected

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default userform1.activecontrol.name

Awesome. That code got me another level into it.

Unfortunately, it evaluates to "multipage1" now. I assume I should modify
the code to loop through "not Multipage" also.

Do you think I assembled this form inefficiently?


"onedaywhen" wrote in message
m...
If the control is contained within a frame control the Frame will be
the active control, which will in turn have its own ActiveControl.
This code should resolve in the active control nested within frames:

Dim Ctrl As MSForms.Control
Set Ctrl = Me.ActiveControl
Do Until Not TypeOf Ctrl Is MSForms.Frame
Set Ctrl = Ctrl.ActiveControl
Loop
MsgBox "Active control = " & Ctrl.Name


"Italian Job" wrote in message

...
Msgbox Userform1.ActiveControl.name

Does or should this work with controls on a multipage form? When I use

it,
all I get is "frame1". No matter which control is selected



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default userform1.activecontrol.name

Awesome. That code got me another level into it.

Unfortunately, it evaluates to "multipage1" now. I assume I should modify
the code to loop through "not Multipage" also.


Yes.

Do you think I assembled this form inefficiently?


Not necessarily. Organizing controls in frames and multipages, even if
they are nested, is usually good organization from a GUI design point
of view. However, this may your code more complex. If this is the
case, consider writing some custom methods to access the controls.


"Italian Job" wrote in message ...

"onedaywhen" wrote in message
m...
If the control is contained within a frame control the Frame will be
the active control, which will in turn have its own ActiveControl.
This code should resolve in the active control nested within frames:

Dim Ctrl As MSForms.Control
Set Ctrl = Me.ActiveControl
Do Until Not TypeOf Ctrl Is MSForms.Frame
Set Ctrl = Ctrl.ActiveControl
Loop
MsgBox "Active control = " & Ctrl.Name


"Italian Job" wrote in message

...
Msgbox Userform1.ActiveControl.name

Does or should this work with controls on a multipage form? When I use

it,
all I get is "frame1". No matter which control is selected

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to filter dates using Userform1 & printing Mel[_5_] Excel Discussion (Misc queries) 0 March 11th 10 04:05 PM
ActiveControl problem DAACKM Excel Discussion (Misc queries) 3 September 9th 08 01:15 AM
UserForm1.Textbox1.SetFocus Question Zane Greer Excel Programming 1 September 14th 03 11:59 AM
Userform1 Border Tom Ogilvy Excel Programming 1 August 13th 03 03:14 PM
Userform1 Border John Wilson Excel Programming 0 August 12th 03 04:08 PM


All times are GMT +1. The time now is 08:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"