Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping through controls on a MultiPage control | Excel Programming | |||
How to loop through controls on a MultiPage | Excel Programming | |||
Multipage Controls - Experts Only | Excel Programming | |||
Multipage & Spinbutton controls on a form | Excel Programming | |||
Events for Controls in a Multipage Control | Excel Programming |