PDA

Click to See Complete Forum and Search --> : Capturing runtime created control events


exlcetoexcel
Mar 25th, 2003, 01:25 PM
I'm adding controls at runtime but need to be able to capture their events. For example.

Set mycmd = Controls("Frame" & (x)).Add("Forms.CheckBox.1")

How do i capture the click event from this newly formed check box.

i tried to name it and write code based on thAt name but i't doesn't work

ie

mycmd.name = "newcheck"&x

Private Sub newcheck1_Click()
Call whatever
End Sub

this won't work.

Anyone have any idea on how to do this, even an idea of were i could find how to do this?

Thanks
-Ted

alex_read
Mar 25th, 2003, 02:07 PM
I susspect you're missing the withevents keyword for this.

Try taking a look at Tom's post here :http://www.vbforums.com/showthread.php?s=&threadid=235463

exlcetoexcel
Mar 25th, 2003, 02:32 PM
WOW I've been programming Excel since 97 and I consider myself to be a good programer and never did figure this one out. I tried the withevents before but for one reason or another it never worked. Guess I gave up to soon. Thanks!!!!!!!!!!!!!!