PC Review


Reply
Thread Tools Rate Thread

Determine ActiveControl on a multipage (tab) control

 
 
Dale Fye
Guest
Posts: n/a
 
      10th Dec 2007
How can I determine what the "ActiveControl" is when the control is on a
multipage (tab) control?

Is there a way to iterate through the control on the multipage tab and
determine which one has the focus?

Dale
--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.

 
Reply With Quote
 
 
 
 
deepakvenkatesan123@gmail.com
Guest
Posts: n/a
 
      10th Dec 2007
create a form/sheet level variable and in the tab click event set it
to the tab number clicked.
 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      10th Dec 2007
Sorry, I probably wasn't clear enough.

I've got a bunch of textboxes on a multipage control. Have a function that
I want to work based on the "ActiveControl", but when I run the following
code, it indicates that the "ActiveControl" is the multipage control, rather
than the textbox that actually has the focus.

I need to determine which textbox has the focus.

Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"(E-Mail Removed)" wrote:

> create a form/sheet level variable and in the tab click event set it
> to the tab number clicked.
>

 
Reply With Quote
 
deepakvenkatesan123@gmail.com
Guest
Posts: n/a
 
      10th Dec 2007
isn't there a GotFocus event for the textboxes? Just put code in each
of the got focus events, for every single control, that sets the
ControlHasFocus variable to the name or Index of the control. That's
how I would do it anyway.
 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      10th Dec 2007
> Sorry, I probably wasn't clear enough.
>
> I've got a bunch of textboxes on a multipage control. Have a function
> that
> I want to work based on the "ActiveControl", but when I run the following
> code, it indicates that the "ActiveControl" is the multipage control,
> rather
> than the textbox that actually has the focus.
>
> I need to determine which textbox has the focus.


I think this will give you what you want...

MultiPage1.SelectedItem.ActiveControl.Name

Rick

 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      11th Dec 2007
Rick,

Exactly what I was looking for. What I finally ended up using is.

Set ctrl = frm.ActiveControl
While TypeOf ctrl Is msforms.MultiPage
Set ctrl = ctrl.SelectedItem.ActiveControl
Wend

Thanks!

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Rick Rothstein (MVP - VB)" wrote:

> > Sorry, I probably wasn't clear enough.
> >
> > I've got a bunch of textboxes on a multipage control. Have a function
> > that
> > I want to work based on the "ActiveControl", but when I run the following
> > code, it indicates that the "ActiveControl" is the multipage control,
> > rather
> > than the textbox that actually has the focus.
> >
> > I need to determine which textbox has the focus.

>
> I think this will give you what you want...
>
> MultiPage1.SelectedItem.ActiveControl.Name
>
> Rick
>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      11th Dec 2007
I'm not sure I understand why you used a While/Wend loop. Since there is
only one ActiveControl on your UserForm, and only one selected Page on the
MultiPage and only one ActiveControl on that selected Page, I don't see what
you are looping through. Of course, I don't know what the rest of your
program is doing, but (off the top of my head) it seems like this should do
what I think your code snippet is attempting to do....

Set ctrl = frm.ActiveControl
If TypeOf ctrl Is msforms.MultiPage Then
Set ctrl = ctrl.SelectedItem.ActiveControl
End If

Do the above assumes, I guess, that you have more than one MultiPage control
on your form and you want to work with whichever one is the currently
ActiveControl. If, however, you only have one MultiPage control on your
form, you should be able to set ctrl to its ActiveControl (on its selected
Page) directly like this...

Set ctrl = frm.MultiPage1.SelectedItem.ActiveControl

(again, that was off the top of my head and untested) where you would use
the name of your MultiPage control in place of the name MultiPage1 that I
used.

Rick


"Dale Fye" <(E-Mail Removed)> wrote in message
news:966CC6DE-180B-4BDE-8CE3-(E-Mail Removed)...
> Rick,
>
> Exactly what I was looking for. What I finally ended up using is.
>
> Set ctrl = frm.ActiveControl
> While TypeOf ctrl Is msforms.MultiPage
> Set ctrl = ctrl.SelectedItem.ActiveControl
> Wend
>
> Thanks!
>
> --
> Don''t forget to rate the post if it was helpful!
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> > Sorry, I probably wasn't clear enough.
>> >
>> > I've got a bunch of textboxes on a multipage control. Have a function
>> > that
>> > I want to work based on the "ActiveControl", but when I run the
>> > following
>> > code, it indicates that the "ActiveControl" is the multipage control,
>> > rather
>> > than the textbox that actually has the focus.
>> >
>> > I need to determine which textbox has the focus.

>>
>> I think this will give you what you want...
>>
>> MultiPage1.SelectedItem.ActiveControl.Name
>>
>> Rick
>>
>>


 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      11th Dec 2007
Okay, I thought about what you are doing some more and think you would want
my first suggested change, not the second one. That is, I think this...

Set ctrl = frm.ActiveControl
If TypeOf ctrl Is msforms.MultiPage Then
Set ctrl = ctrl.SelectedItem.ActiveControl
End If

does what your last posted code (the one with the While/Wend loop) was
trying to do.

Rick


"Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> I'm not sure I understand why you used a While/Wend loop. Since there is
> only one ActiveControl on your UserForm, and only one selected Page on the
> MultiPage and only one ActiveControl on that selected Page, I don't see
> what you are looping through. Of course, I don't know what the rest of
> your program is doing, but (off the top of my head) it seems like this
> should do what I think your code snippet is attempting to do....
>
> Set ctrl = frm.ActiveControl
> If TypeOf ctrl Is msforms.MultiPage Then
> Set ctrl = ctrl.SelectedItem.ActiveControl
> End If
>
> Do the above assumes, I guess, that you have more than one MultiPage
> control on your form and you want to work with whichever one is the
> currently ActiveControl. If, however, you only have one MultiPage control
> on your form, you should be able to set ctrl to its ActiveControl (on its
> selected Page) directly like this...
>
> Set ctrl = frm.MultiPage1.SelectedItem.ActiveControl
>
> (again, that was off the top of my head and untested) where you would use
> the name of your MultiPage control in place of the name MultiPage1 that I
> used.
>
> Rick
>
>
> "Dale Fye" <(E-Mail Removed)> wrote in message
> news:966CC6DE-180B-4BDE-8CE3-(E-Mail Removed)...
>> Rick,
>>
>> Exactly what I was looking for. What I finally ended up using is.
>>
>> Set ctrl = frm.ActiveControl
>> While TypeOf ctrl Is msforms.MultiPage
>> Set ctrl = ctrl.SelectedItem.ActiveControl
>> Wend
>>
>> Thanks!
>>
>> --
>> Don''t forget to rate the post if it was helpful!
>>
>> email address is invalid
>> Please reply to newsgroup only.
>>
>>
>>
>> "Rick Rothstein (MVP - VB)" wrote:
>>
>>> > Sorry, I probably wasn't clear enough.
>>> >
>>> > I've got a bunch of textboxes on a multipage control. Have a function
>>> > that
>>> > I want to work based on the "ActiveControl", but when I run the
>>> > following
>>> > code, it indicates that the "ActiveControl" is the multipage control,
>>> > rather
>>> > than the textbox that actually has the focus.
>>> >
>>> > I need to determine which textbox has the focus.
>>>
>>> I think this will give you what you want...
>>>
>>> MultiPage1.SelectedItem.ActiveControl.Name
>>>
>>> Rick
>>>
>>>

>


 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      11th Dec 2007
Sorry, I didn't clarify.

It turns out that at least one of the textboxes I want to work with is on a
multipage imbedded within another multipage.

Thanks again.

Dale
--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Rick Rothstein (MVP - VB)" wrote:

> Okay, I thought about what you are doing some more and think you would want
> my first suggested change, not the second one. That is, I think this...
>
> Set ctrl = frm.ActiveControl
> If TypeOf ctrl Is msforms.MultiPage Then
> Set ctrl = ctrl.SelectedItem.ActiveControl
> End If
>
> does what your last posted code (the one with the While/Wend loop) was
> trying to do.
>
> Rick
>
>
> "Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
> > I'm not sure I understand why you used a While/Wend loop. Since there is
> > only one ActiveControl on your UserForm, and only one selected Page on the
> > MultiPage and only one ActiveControl on that selected Page, I don't see
> > what you are looping through. Of course, I don't know what the rest of
> > your program is doing, but (off the top of my head) it seems like this
> > should do what I think your code snippet is attempting to do....
> >
> > Set ctrl = frm.ActiveControl
> > If TypeOf ctrl Is msforms.MultiPage Then
> > Set ctrl = ctrl.SelectedItem.ActiveControl
> > End If
> >
> > Do the above assumes, I guess, that you have more than one MultiPage
> > control on your form and you want to work with whichever one is the
> > currently ActiveControl. If, however, you only have one MultiPage control
> > on your form, you should be able to set ctrl to its ActiveControl (on its
> > selected Page) directly like this...
> >
> > Set ctrl = frm.MultiPage1.SelectedItem.ActiveControl
> >
> > (again, that was off the top of my head and untested) where you would use
> > the name of your MultiPage control in place of the name MultiPage1 that I
> > used.
> >
> > Rick
> >
> >
> > "Dale Fye" <(E-Mail Removed)> wrote in message
> > news:966CC6DE-180B-4BDE-8CE3-(E-Mail Removed)...
> >> Rick,
> >>
> >> Exactly what I was looking for. What I finally ended up using is.
> >>
> >> Set ctrl = frm.ActiveControl
> >> While TypeOf ctrl Is msforms.MultiPage
> >> Set ctrl = ctrl.SelectedItem.ActiveControl
> >> Wend
> >>
> >> Thanks!
> >>
> >> --
> >> Don''t forget to rate the post if it was helpful!
> >>
> >> email address is invalid
> >> Please reply to newsgroup only.
> >>
> >>
> >>
> >> "Rick Rothstein (MVP - VB)" wrote:
> >>
> >>> > Sorry, I probably wasn't clear enough.
> >>> >
> >>> > I've got a bunch of textboxes on a multipage control. Have a function
> >>> > that
> >>> > I want to work based on the "ActiveControl", but when I run the
> >>> > following
> >>> > code, it indicates that the "ActiveControl" is the multipage control,
> >>> > rather
> >>> > than the textbox that actually has the focus.
> >>> >
> >>> > I need to determine which textbox has the focus.
> >>>
> >>> I think this will give you what you want...
> >>>
> >>> MultiPage1.SelectedItem.ActiveControl.Name
> >>>
> >>> Rick
> >>>
> >>>

> >

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      11th Dec 2007
Ah! Okay, I see... thanks for clarifying that.

Rick


"Dale Fye" <(E-Mail Removed)> wrote in message
news:0C000594-95FE-40F9-B0BB-(E-Mail Removed)...
> Sorry, I didn't clarify.
>
> It turns out that at least one of the textboxes I want to work with is on
> a
> multipage imbedded within another multipage.
>
> Thanks again.
>
> Dale
> --
> Don''t forget to rate the post if it was helpful!
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> Okay, I thought about what you are doing some more and think you would
>> want
>> my first suggested change, not the second one. That is, I think this...
>>
>> Set ctrl = frm.ActiveControl
>> If TypeOf ctrl Is msforms.MultiPage Then
>> Set ctrl = ctrl.SelectedItem.ActiveControl
>> End If
>>
>> does what your last posted code (the one with the While/Wend loop) was
>> trying to do.
>>
>> Rick
>>
>>
>> "Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
>> message news:(E-Mail Removed)...
>> > I'm not sure I understand why you used a While/Wend loop. Since there
>> > is
>> > only one ActiveControl on your UserForm, and only one selected Page on
>> > the
>> > MultiPage and only one ActiveControl on that selected Page, I don't see
>> > what you are looping through. Of course, I don't know what the rest of
>> > your program is doing, but (off the top of my head) it seems like this
>> > should do what I think your code snippet is attempting to do....
>> >
>> > Set ctrl = frm.ActiveControl
>> > If TypeOf ctrl Is msforms.MultiPage Then
>> > Set ctrl = ctrl.SelectedItem.ActiveControl
>> > End If
>> >
>> > Do the above assumes, I guess, that you have more than one MultiPage
>> > control on your form and you want to work with whichever one is the
>> > currently ActiveControl. If, however, you only have one MultiPage
>> > control
>> > on your form, you should be able to set ctrl to its ActiveControl (on
>> > its
>> > selected Page) directly like this...
>> >
>> > Set ctrl = frm.MultiPage1.SelectedItem.ActiveControl
>> >
>> > (again, that was off the top of my head and untested) where you would
>> > use
>> > the name of your MultiPage control in place of the name MultiPage1 that
>> > I
>> > used.
>> >
>> > Rick
>> >
>> >
>> > "Dale Fye" <(E-Mail Removed)> wrote in message
>> > news:966CC6DE-180B-4BDE-8CE3-(E-Mail Removed)...
>> >> Rick,
>> >>
>> >> Exactly what I was looking for. What I finally ended up using is.
>> >>
>> >> Set ctrl = frm.ActiveControl
>> >> While TypeOf ctrl Is msforms.MultiPage
>> >> Set ctrl = ctrl.SelectedItem.ActiveControl
>> >> Wend
>> >>
>> >> Thanks!
>> >>
>> >> --
>> >> Don''t forget to rate the post if it was helpful!
>> >>
>> >> email address is invalid
>> >> Please reply to newsgroup only.
>> >>
>> >>
>> >>
>> >> "Rick Rothstein (MVP - VB)" wrote:
>> >>
>> >>> > Sorry, I probably wasn't clear enough.
>> >>> >
>> >>> > I've got a bunch of textboxes on a multipage control. Have a
>> >>> > function
>> >>> > that
>> >>> > I want to work based on the "ActiveControl", but when I run the
>> >>> > following
>> >>> > code, it indicates that the "ActiveControl" is the multipage
>> >>> > control,
>> >>> > rather
>> >>> > than the textbox that actually has the focus.
>> >>> >
>> >>> > I need to determine which textbox has the focus.
>> >>>
>> >>> I think this will give you what you want...
>> >>>
>> >>> MultiPage1.SelectedItem.ActiveControl.Name
>> >>>
>> >>> Rick
>> >>>
>> >>>
>> >

>>
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveControl returns "wrong" value if ctrl is on a multipage ctrl =?Utf-8?B?RGFsZSBGeWU=?= Microsoft Excel Programming 3 15th Oct 2007 04:26 PM
[VB2005EE] accessing control-specific functions via form's ActiveControl Aphazel Microsoft VB .NET 4 11th May 2006 10:42 PM
Calendar Control & ActiveControl =?Utf-8?B?TWFyY3VzIEI=?= Microsoft Excel Programming 0 15th Mar 2006 10:08 AM
Looking for eloquent solution: Determine of any control on a page of multipage has been altered (userform) KR Microsoft Excel Programming 0 13th Dec 2004 09:04 PM
Form.ActiveControl method does not work for control created at run-time ??? James Ramaley Microsoft VB .NET 1 17th Aug 2004 09:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:43 PM.