Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Listbox.RowSource problem

Given a simple form with one listbox, I have loaded the code as follows:

Private Sub UserForm_Initialize()
ListBox1.RowSource = "A1:A26"
End Sub
Private Sub ListBox1_Click()
ListBox1.RowSource = ""
ListBox1.RowSource = "A9:A14"
End Sub

where A1 .. A26 are the letters of the alphabet.
Question 1:
Putting a break in Listbox1_Click() shows that when I click on the listbox,
ListBox1_Click() fires two times. Why is that so?
Question 2:
When I click on the listbox, why aren't the contents of the listbox changed
to reflect the new rowsource?

Thanks for any help!
-Tim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Listbox.RowSource problem

Tim,

If you put this code in a module

Private Sub UserForm_Initialize()
Userform1.ListBox1.RowSource = "A1:A26"
End Sub
and this in your code for userform
Private Sub ListBox1_Click()
Unload userform1
With Userform1
.ListBox1.RowSource = ""
.ListBox1.RowSource = "A9:A14"
..show
End With
End Sub
I beleive it should do what you want.

Charles
"Tim Coddington" wrote in message
...
Given a simple form with one listbox, I have loaded the code as follows:

Private Sub UserForm_Initialize()
ListBox1.RowSource = "A1:A26"
End Sub
Private Sub ListBox1_Click()
ListBox1.RowSource = ""
ListBox1.RowSource = "A9:A14"
End Sub

where A1 .. A26 are the letters of the alphabet.
Question 1:
Putting a break in Listbox1_Click() shows that when I click on the
listbox,
ListBox1_Click() fires two times. Why is that so?
Question 2:
When I click on the listbox, why aren't the contents of the listbox
changed
to reflect the new rowsource?

Thanks for any help!
-Tim




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Listbox.RowSource problem

Are you saying that every time I need to reset .RowSource I need to save all
my other fields on that form, unload the form, adjust .RowSource, and then
reload all my other fields????

"Charles Harmon" wrote in message
...
Tim,

If you put this code in a module

Private Sub UserForm_Initialize()
Userform1.ListBox1.RowSource = "A1:A26"
End Sub
and this in your code for userform
Private Sub ListBox1_Click()
Unload userform1
With Userform1
.ListBox1.RowSource = ""
.ListBox1.RowSource = "A9:A14"
.show
End With
End Sub
I beleive it should do what you want.

Charles
"Tim Coddington" wrote in message
...
Given a simple form with one listbox, I have loaded the code as follows:

Private Sub UserForm_Initialize()
ListBox1.RowSource = "A1:A26"
End Sub
Private Sub ListBox1_Click()
ListBox1.RowSource = ""
ListBox1.RowSource = "A9:A14"
End Sub

where A1 .. A26 are the letters of the alphabet.
Question 1:
Putting a break in Listbox1_Click() shows that when I click on the
listbox,
ListBox1_Click() fires two times. Why is that so?
Question 2:
When I click on the listbox, why aren't the contents of the listbox
changed
to reflect the new rowsource?

Thanks for any help!
-Tim






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Listbox.RowSource problem

Tim,
I think when you Initialize the userform it retains the current information.
Then when you select an item in the listbox (even though you say to clear
the listbox) it still holds the image from the Initialization. By dismissing
the form then recall it now takes on the new properties. Maybe someone else
can explain it better than me.

Charles

"Tim Coddington" wrote in message
...
Are you saying that every time I need to reset .RowSource I need to save
all
my other fields on that form, unload the form, adjust .RowSource, and then
reload all my other fields????

"Charles Harmon" wrote in message
...
Tim,

If you put this code in a module

Private Sub UserForm_Initialize()
Userform1.ListBox1.RowSource = "A1:A26"
End Sub
and this in your code for userform
Private Sub ListBox1_Click()
Unload userform1
With Userform1
.ListBox1.RowSource = ""
.ListBox1.RowSource = "A9:A14"
.show
End With
End Sub
I beleive it should do what you want.

Charles
"Tim Coddington" wrote in message
...
Given a simple form with one listbox, I have loaded the code as
follows:

Private Sub UserForm_Initialize()
ListBox1.RowSource = "A1:A26"
End Sub
Private Sub ListBox1_Click()
ListBox1.RowSource = ""
ListBox1.RowSource = "A9:A14"
End Sub

where A1 .. A26 are the letters of the alphabet.
Question 1:
Putting a break in Listbox1_Click() shows that when I click on the
listbox,
ListBox1_Click() fires two times. Why is that so?
Question 2:
When I click on the listbox, why aren't the contents of the listbox
changed
to reflect the new rowsource?

Thanks for any help!
-Tim








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Listbox.RowSource problem

Thanks much Mr. Harmon. I suppose I'm stuck with .additem type technology.

"Charles Harmon" wrote in message
...
Tim,
I think when you Initialize the userform it retains the current

information.
Then when you select an item in the listbox (even though you say to clear
the listbox) it still holds the image from the Initialization. By

dismissing
the form then recall it now takes on the new properties. Maybe someone

else
can explain it better than me.

Charles

"Tim Coddington" wrote in message
...
Are you saying that every time I need to reset .RowSource I need to save
all
my other fields on that form, unload the form, adjust .RowSource, and

then
reload all my other fields????

"Charles Harmon" wrote in message
...
Tim,

If you put this code in a module

Private Sub UserForm_Initialize()
Userform1.ListBox1.RowSource = "A1:A26"
End Sub
and this in your code for userform
Private Sub ListBox1_Click()
Unload userform1
With Userform1
.ListBox1.RowSource = ""
.ListBox1.RowSource = "A9:A14"
.show
End With
End Sub
I beleive it should do what you want.

Charles
"Tim Coddington" wrote in message
...
Given a simple form with one listbox, I have loaded the code as
follows:

Private Sub UserForm_Initialize()
ListBox1.RowSource = "A1:A26"
End Sub
Private Sub ListBox1_Click()
ListBox1.RowSource = ""
ListBox1.RowSource = "A9:A14"
End Sub

where A1 .. A26 are the letters of the alphabet.
Question 1:
Putting a break in Listbox1_Click() shows that when I click on the
listbox,
ListBox1_Click() fires two times. Why is that so?
Question 2:
When I click on the listbox, why aren't the contents of the listbox
changed
to reflect the new rowsource?

Thanks for any help!
-Tim












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Listbox.RowSource problem

Tim,
It was suggested that you use Dbl_Click by mangesh_yadav on the Forum. That
should solve your problem.

"Tim Coddington" wrote in message
...
Thanks much Mr. Harmon. I suppose I'm stuck with .additem type
technology.

"Charles Harmon" wrote in message
...
Tim,
I think when you Initialize the userform it retains the current

information.
Then when you select an item in the listbox (even though you say to clear
the listbox) it still holds the image from the Initialization. By

dismissing
the form then recall it now takes on the new properties. Maybe someone

else
can explain it better than me.

Charles

"Tim Coddington" wrote in message
...
Are you saying that every time I need to reset .RowSource I need to
save
all
my other fields on that form, unload the form, adjust .RowSource, and

then
reload all my other fields????

"Charles Harmon" wrote in message
...
Tim,

If you put this code in a module

Private Sub UserForm_Initialize()
Userform1.ListBox1.RowSource = "A1:A26"
End Sub
and this in your code for userform
Private Sub ListBox1_Click()
Unload userform1
With Userform1
.ListBox1.RowSource = ""
.ListBox1.RowSource = "A9:A14"
.show
End With
End Sub
I beleive it should do what you want.

Charles
"Tim Coddington" wrote in message
...
Given a simple form with one listbox, I have loaded the code as
follows:

Private Sub UserForm_Initialize()
ListBox1.RowSource = "A1:A26"
End Sub
Private Sub ListBox1_Click()
ListBox1.RowSource = ""
ListBox1.RowSource = "A9:A14"
End Sub

where A1 .. A26 are the letters of the alphabet.
Question 1:
Putting a break in Listbox1_Click() shows that when I click on the
listbox,
ListBox1_Click() fires two times. Why is that so?
Question 2:
When I click on the listbox, why aren't the contents of the listbox
changed
to reflect the new rowsource?

Thanks for any help!
-Tim












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
Listbox rowsource on Userform Wendy Excel Discussion (Misc queries) 6 February 28th 08 05:46 PM
RowSource in ListBox aet-inc[_2_] Excel Programming 1 December 3rd 03 12:41 AM
ListBox Rowsource Limitation?? Dave Baranas Excel Programming 2 September 29th 03 05:01 PM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
listbox rowsource Christy[_2_] Excel Programming 4 September 20th 03 11:44 PM


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