Posted to microsoft.public.excel.programming
|
|
Determine ActiveControl on a multipage (tab) control
Ah! Okay, I see... thanks for clarifying that.
Rick
"Dale Fye" wrote in message
...
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)" wrote in
message ...
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" wrote in message
...
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
|