Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a UserForm1 with a ListBox1 in it. When I click on an entry from
ListBox1, UserForm2 appears. UserForm2 has the equivalent of "OK" and "Cancel" buttons on it (among other things). I had been so busy testing other features that it never occurred to me to test the Cancel button until now. What I found is that, when Cancel is clicked, UserForm2 unloads (as it should) and then immediately reappears. The "UserForm2.Show" line of code is the first line in the ListBox1_Click() sub. I assumed that, since an entry was still selected in ListBox1, it was counting that as a click and re-running the ListBox1_Click() sub. To fix this, I added this line of code to the CommandButton2_Click() sub (the Cancel button): UserForm1.ListBox1.ListIndex = 0. That line of code came after the "Unload UserForm2" line in the same sub. However, I then got a Run-time error 400: Form already displayed; can't show modally. The highlighted line of code was the UserForm2.Show line in the ListBox1_Click() sub. How can I click the Cancel button on UserForm2, unload UserForm2, and have ListBox1 (in UserForm1) sitting there ready for me to choose a new entry? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
fill userform textbox from userform listbox clik event | Excel Programming | |||
userform listbox cannot get listbox.value to transfer back to main sub | Excel Programming | |||
Userform interaction with the VBA code | Excel Programming | |||
Flow of control in VBA Question - Userform Interaction | Excel Programming | |||
UserForm Interaction | Excel Programming |