Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to determine which dynamically generated control was clicked

I have a worksheet that updates from a database query every fiv
minutes. With each update, a row is generated for each record in th
query. The number of records returned from the query varies with eac
new query. I have figured out (many, many thanks to Chip Pearson) ho
to dynamically generate a command button and its attached code for eac
record displayed on the worksheet.

However, now I need to figure out how to determine which command butto
was pressed when the user clicks on one of the command button
generated at runtime.

For example, the code that is generated for each command button look
like this:

Sub Button3_Click()

'Now I need to figure out, in this case, that button 3 (as oppose
to button 4 or 5) was pressed

End Sub

Any ideas or help would be very greatly appreciated!! Thank you i
advance

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to determine which dynamically generated control was clicked

Surely, if it is the Button3 event, you must already know it is button 3?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"llowwelll " wrote in message
...
I have a worksheet that updates from a database query every five
minutes. With each update, a row is generated for each record in the
query. The number of records returned from the query varies with each
new query. I have figured out (many, many thanks to Chip Pearson) how
to dynamically generate a command button and its attached code for each
record displayed on the worksheet.

However, now I need to figure out how to determine which command button
was pressed when the user clicks on one of the command buttons
generated at runtime.

For example, the code that is generated for each command button looks
like this:

Sub Button3_Click()

'Now I need to figure out, in this case, that button 3 (as opposed
to button 4 or 5) was pressed

End Sub

Any ideas or help would be very greatly appreciated!! Thank you in
advance!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default How to determine which dynamically generated control was clicked

Since the OP talked about "attached code" rather than "event", it could
be that the button is a Forms control with an attached macro...


In article ,
"Bob Phillips" wrote:

Surely, if it is the Button3 event, you must already know it is button 3?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to determine which dynamically generated control was clicked

Maybe, the _Click may have misled me.

Let's await the OP's response<G.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JE McGimpsey" wrote in message
...
Since the OP talked about "attached code" rather than "event", it could
be that the button is a Forms control with an attached macro...


In article ,
"Bob Phillips" wrote:

Surely, if it is the Button3 event, you must already know it is button

3?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default How to determine which dynamically generated control was clicked

Stick this in your attached Macro:

Sub MyMacro(
MsgBox Application.Calle
...
End Sub
----- llowwelll wrote: ----

I have a worksheet that updates from a database query every fiv
minutes. With each update, a row is generated for each record in th
query. The number of records returned from the query varies with eac
new query. I have figured out (many, many thanks to Chip Pearson) ho
to dynamically generate a command button and its attached code for eac
record displayed on the worksheet

However, now I need to figure out how to determine which command butto
was pressed when the user clicks on one of the command button
generated at runtime.

For example, the code that is generated for each command button look
like this

Sub Button3_Click(

'Now I need to figure out, in this case, that button 3 (as oppose
to button 4 or 5) was presse

End Su

Any ideas or help would be very greatly appreciated!! Thank you i
advance


--
Message posted from http://www.ExcelForum.com




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
Dynamically Generated Range using Macro [email protected] Excel Worksheet Functions 2 July 15th 06 08:12 AM
Determine when checkbox is clicked wAyne Excel Discussion (Misc queries) 1 February 21st 06 08:35 PM
Return Index of Control Object Clicked! gr8guy Excel Programming 3 May 11th 04 05:24 AM
How to determine which button was clicked on the modified right-click menu Patrick Choi Excel Programming 1 September 1st 03 02:07 PM
How to code event for dynamically generated checkboxes Chong Moua Excel Programming 0 July 9th 03 08:18 PM


All times are GMT +1. The time now is 09:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"