Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Identifying controls on MultiPage Pages

Hi,

I would like to present a userform to my customers that has on it a
multipage with a number of pages, and on each page a varying number of
checkboxes.

Say there are two pages, "Page1" and "Page2," and later when I'm
running through all of the checkboxes in code, I'd like to know from
which page each checkbox that's checked came from.

I usually use something like this on the form:

Private Sub CommandButton1_Click()
Dim i As Integer
Dim obj as Object

For Each obj In Me.Controls
If TypeName(obj) = "CheckBox" Then
If obj.value = True Then
...
End If
End If
Next

If any given checkbox is checked, is there a way to tell which page it
was on? Although VBA Help indicates each Page of a MultiPage can act
as a container for controls, I have had no luck trying to link a
checkbox to a Page after the fact.

TIA for any help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Identifying controls on MultiPage Pages


Hello Rhumba,

This code will return the owner of any CheckBox that is checked. The
Parent property will return the name of the "Container" object for the
control. Some common container objects are UserForms, Frames, and
MultiPage objects. If you have a Checkbox in a Frame, the first
instance of the Parent property is the name of the Frame, the second is
the MultiPage, and then the UserForm.

For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "CheckBox" And Ctrl.Object.Value = True
Then
Owner = Ctrl.Parent.Name
End If
Next Ctrl


To get the CheckBox Owner on a Frame would be...
Owner = Ctrl.Parent.Parent.Name

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=509221

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Identifying controls on MultiPage Pages

On Tue, 7 Feb 2006 02:31:29 -0600, Leith Ross
wrote:


Hello Rhumba,

This code will return the owner of any CheckBox that is checked. The
Parent property will return the name of the "Container" object for the
control. Some common container objects are UserForms, Frames, and
MultiPage objects. If you have a Checkbox in a Frame, the first
instance of the Parent property is the name of the Frame, the second is
the MultiPage, and then the UserForm.

For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "CheckBox" And Ctrl.Object.Value = True
Then
Owner = Ctrl.Parent.Name
End If
Next Ctrl


To get the CheckBox Owner on a Frame would be...
Owner = Ctrl.Parent.Parent.Name

Sincerely,
Leith Ross



Hi Leith,

I had tried the Parent property previously, but apparently didn't have
the correct syntax. Many thanks for a very clear explanation!

Regards,
Rhumba

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
Looping through controls on a MultiPage control Paul Martin Excel Programming 3 April 26th 05 05:08 AM
How to loop through controls on a MultiPage 42N83W Excel Programming 11 February 14th 05 11:32 PM
Multipage Controls - Experts Only Dee Veloper[_2_] Excel Programming 1 January 25th 05 11:57 PM
Multipage & Spinbutton controls on a form Bhuktar S Excel Programming 1 April 21st 04 01:50 PM
Events for Controls in a Multipage Control George[_18_] Excel Programming 4 February 18th 04 05:56 PM


All times are GMT +1. The time now is 08:49 PM.

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"