Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Userform - Return Control Clicked

I have a userform that is using a multipage with 13-14 pages and on
each page there will be 5-6 controls (labels) that can be selected.

Instead of writing an event procedure for 13-14x5-6 labels is it
possible to write a generic procedure that will return which label was
selected (double clicked)

To clarify, if on multipage 1 I clicked label 3 I would like the Name
of Label3 to be used in launching a new userform with Label3.name used
as one of the variables on the new userform.
If I click on multipage 12 label 63 i would like label63.name to be
returned.

My original thought was to look at MSForms.Controls but I'm having a
hard time. I was trying to use userform_dblclick or multipage_dblclick
however double clicking on a label (the behaviour i'm trying to
capture) does not get captured.

Any Ideas? Thanks in advance,
mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Userform - Return Control Clicked

your statement "I was trying to use userform_dblclick or multipage_dblclick
however double clicking on a label (the behaviour i'm trying to
capture) does not get captured." is confusing. The label does have a
double click event if you right click the Label, then View Code you will see
the DblClick in the Declarations drop down pane. You would have to write the
event code to make it perform as you have described your requirement, just
like any other event code.


"MDubbelboer" wrote:

I have a userform that is using a multipage with 13-14 pages and on
each page there will be 5-6 controls (labels) that can be selected.

Instead of writing an event procedure for 13-14x5-6 labels is it
possible to write a generic procedure that will return which label was
selected (double clicked)

To clarify, if on multipage 1 I clicked label 3 I would like the Name
of Label3 to be used in launching a new userform with Label3.name used
as one of the variables on the new userform.
If I click on multipage 12 label 63 i would like label63.name to be
returned.

My original thought was to look at MSForms.Controls but I'm having a
hard time. I was trying to use userform_dblclick or multipage_dblclick
however double clicking on a label (the behaviour i'm trying to
capture) does not get captured.

Any Ideas? Thanks in advance,
mark

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Userform - Return Control Clicked

The object that raises the event is the label and that event is not also
raised in the parent object being either the form or multipage. To that end
you need to write event code for each label. That code however could just be
a call to one procedure designed to take the control as it's argument...

Private Sub Label1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Call test(Label1)
End Sub

Sub test(ByVal obj As Object)
MsgBox obj.Name
End Sub
--
HTH...

Jim Thomlinson


"MDubbelboer" wrote:

I have a userform that is using a multipage with 13-14 pages and on
each page there will be 5-6 controls (labels) that can be selected.

Instead of writing an event procedure for 13-14x5-6 labels is it
possible to write a generic procedure that will return which label was
selected (double clicked)

To clarify, if on multipage 1 I clicked label 3 I would like the Name
of Label3 to be used in launching a new userform with Label3.name used
as one of the variables on the new userform.
If I click on multipage 12 label 63 i would like label63.name to be
returned.

My original thought was to look at MSForms.Controls but I'm having a
hard time. I was trying to use userform_dblclick or multipage_dblclick
however double clicking on a label (the behaviour i'm trying to
capture) does not get captured.

Any Ideas? Thanks in advance,
mark

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Userform - Return Control Clicked

On Aug 8, 1:39*pm, JLGWhiz wrote:
your statement "I was trying to use userform_dblclick or multipage_dblclick
*however double clicking on a label (the behaviour i'm trying to
*capture) does not get captured." is confusing. *The label does have a
double click event if you right click the Label, then View Code you will see
the DblClick in the Declarations drop down pane. *You would have to write the
event code to make it perform as you have described your requirement, just
like any other event code.

"MDubbelboer" wrote:
I have a userform that is using a multipage with 13-14 pages and on
each page there will be 5-6 controls (labels) that can be selected.


Instead of writing an event procedure for 13-14x5-6 labels is it
possible to write a generic procedure that will return which label was
selected (double clicked)


To clarify, if on multipage 1 I clicked label 3 I would like the Name
of Label3 to be used in launching a new userform with Label3.name used
as one of the variables on the new userform.
If I click on multipage 12 label 63 *i would like label63.name to be
returned.


My original thought was to look at MSForms.Controls but I'm having a
hard time. I was trying to use userform_dblclick or multipage_dblclick
however double clicking on a label (the behaviour i'm trying to
capture) does not get captured.


Any Ideas? Thanks in advance,
mark


i understand that. i was trying to avoid using the label events
because i did not want to have to make a specific code for each label.

From your statement and jim Thomlinson's statement it looks like I'm
out of luck and will have to do exactly that however.

thanks for reading
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Userform - Return Control Clicked

John Walkenbach shows how to use a class module to create a group of
commandbuttons on a userform so that clicking any button runs the same code.

You can find John's notes he
http://spreadsheetpage.com/index.php..._subrouti ne/

I modified his code to use labels instead of commandbuttons.

This goes in the Class1 module:

Public WithEvents LabelGroup As MSForms.Label
Private Sub LabelGroup_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "Hello from " & LabelGroup.Name & vbLf & LabelGroup.Caption
End Sub

This goes in a General module:

Option Explicit
Dim myLabels() As New Class1
Sub ShowDialog()
Dim LabelCount As Long
Dim ctl As Control

LabelCount = 0
For Each ctl In UserForm1.Controls
If TypeOf ctl Is MSForms.Label Then
LabelCount = LabelCount + 1
ReDim Preserve myLabels(1 To LabelCount)
Set myLabels(LabelCount).LabelGroup = ctl
End If
Next ctl
UserForm1.Show
End Sub




MDubbelboer wrote:

I have a userform that is using a multipage with 13-14 pages and on
each page there will be 5-6 controls (labels) that can be selected.

Instead of writing an event procedure for 13-14x5-6 labels is it
possible to write a generic procedure that will return which label was
selected (double clicked)

To clarify, if on multipage 1 I clicked label 3 I would like the Name
of Label3 to be used in launching a new userform with Label3.name used
as one of the variables on the new userform.
If I click on multipage 12 label 63 i would like label63.name to be
returned.

My original thought was to look at MSForms.Controls but I'm having a
hard time. I was trying to use userform_dblclick or multipage_dblclick
however double clicking on a label (the behaviour i'm trying to
capture) does not get captured.

Any Ideas? Thanks in advance,
mark


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Userform - Return Control Clicked

On Aug 8, 4:29*pm, Dave Peterson wrote:
John Walkenbach shows how to use a class module to create a group of
commandbuttons on a userform so that clicking any button runs the same code.

You can find John's notes hehttp://spreadsheetpage.com/index.php...e_userform_but...

I modified his code to use labels instead of commandbuttons.

This goes in the Class1 module:

Public WithEvents LabelGroup As MSForms.Label
Private Sub LabelGroup_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
* * MsgBox "Hello from " & LabelGroup.Name & vbLf & LabelGroup.Caption
End Sub

This goes in a General module:

Option Explicit
Dim myLabels() As New Class1
Sub ShowDialog()
* * Dim LabelCount As Long
* * Dim ctl As Control

* * LabelCount = 0
* * For Each ctl In UserForm1.Controls
* * * * If TypeOf ctl Is MSForms.Label Then
* * * * * * LabelCount = LabelCount + 1
* * * * * * ReDim Preserve myLabels(1 To LabelCount)
* * * * * * * * Set myLabels(LabelCount).LabelGroup = ctl
* * * * End If
* * Next ctl
* * UserForm1.Show
End Sub



MDubbelboer wrote:

I have a userform that is using a multipage with 13-14 pages and on
each page there will be 5-6 controls (labels) that can be selected.


Instead of writing an event procedure for 13-14x5-6 labels is it
possible to write a generic procedure that will return which label was
selected (double clicked)


To clarify, if on multipage 1 I clicked label 3 I would like the Name
of Label3 to be used in launching a new userform with Label3.name used
as one of the variables on the new userform.
If I click on multipage 12 label 63 *i would like label63.name to be
returned.


My original thought was to look at MSForms.Controls but I'm having a
hard time. I was trying to use userform_dblclick or multipage_dblclick
however double clicking on a label (the behaviour i'm trying to
capture) does not get captured.


Any Ideas? Thanks in advance,
mark


--

Dave Peterson


Freaking Eh!

thanks dave, took me a while to get back here but that's awesome.
thanks.
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
How do you .DELETE a (sub-menu) Control that was clicked? Air_Cooled_Nut[_11_] Excel Programming 2 April 1st 08 06:42 PM
Return Control to Userform Stephen Newman[_2_] Excel Programming 6 January 21st 08 02:32 AM
Problem: Control Toolbox Control resizes when clicked Ed Excel Programming 1 July 27th 05 07:55 AM
Return Index of Control Object Clicked! gr8guy Excel Programming 3 May 11th 04 05:24 AM
Keep userform visible, but return control to calling routine Ryan Poth[_2_] Excel Programming 0 August 21st 03 05:28 AM


All times are GMT +1. The time now is 08:19 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"