LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default ListBox / UserForm interaction

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
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
fill userform textbox from userform listbox clik event GregJG[_21_] Excel Programming 3 December 7th 08 04:47 PM
userform listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
Userform interaction with the VBA code [email protected] Excel Programming 0 March 11th 05 03:45 PM
Flow of control in VBA Question - Userform Interaction Alan Excel Programming 3 December 23rd 04 01:12 PM
UserForm Interaction Bob Phillips[_5_] Excel Programming 0 September 22nd 03 08:12 PM


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