The ultimate goal is to create a Userform at run-time.
The problem is writing event code for that Userform.
The current situation is:
I have a userform. (Created with the VBE, not at run-time.) There is one command button on that userform. The code module for that userform is this
and nothing else.
I am trying to add a CommandButton1_Click routine to that module. My code for that is in a normal code module.
When I run showTheForm, the form appears (looking past the form, I can see that the code has been added to the userform's code module), but when I click on the button, nothing happens.
I dismiss the form, the MsgBox appears, and then the userform (second incarnation) again. And again the command button does nothing.
Dismissing the userform (via the corner X) ends showTheForm.
At this point the Private Sub CommandButton1_Click routine is in UserForm1's code module.
Once again, I run showTheForm, this time starting with the commandbutton routine already in the userform's module.
This time, the command button works on both incarnations.
Something about calling a macro, some behind-the-scenes intializing routine is connecting the button and the code.
How do I make that connection while running my routine? How can I get the CommandButton to run the _Click routine on the first runthrough of showTheForm?
(Mac OS 9.22, Excel '98)
also posted to OzGrid
Bookmarks