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: 24
Default listbox click event help

I have a userform on which I have TextBox1, TextBox2, TextBox3,
ListBox1, and CommandButton1. The user enters info into the three
textboxes then clicks CommandButton1 to update ListBox1 with the data
as shown in the following code:

'If no selection is made in the listbox then create a new
listbox item...
If ListBox1.ListIndex = -1 Then
ListBox1.AddItem TextBox1.Value
ListBox1.List(ListBox1.ListCount - 1, 1) =
TextBox2.Value
ListBox1.List(ListBox1.ListCount - 1, 2) =
TextBox3.Value
'Else if a selection is made in the listbox, update the
values
'to those in the textboxes.
Else
ListBox1.List(ListBox1.ListIndex, 1) =
TextBox1.Value
ListBox1.List(ListBox1.ListIndex, 2) =
TextBox2.Value
ListBox1.List(ListBox1.ListIndex, 3) =
TextBox3.Value
End If

My problem is that I have a ListBox1_Click event that, when clicked,
populates TextBox1, TextBox2, and TextBox3 with the information from
the row selected in ListBox1 as follows:

Private Sub ListBox1_Click()

If ListBox1.ListIndex < -1 Then
TextBox1.Value = ListBox1.List(ListBox1.ListIndex, 1)
TextBox2.Value = ListBox1.List(ListBox1.ListIndex, 2)
TextBox3.Value = ListBox1.List(ListBox1.ListIndex, 3)
End If

End Sub

So when I select a row from ListBox1, TextBox1, TextBox2, and TextBox3
are populated. The idea is to be able to populate the textboxes,
modify them, then click CommandButton1 to update the information on
that line. It appears that the ListBox1_Click event is being fired
again when the data is modified, reverting to the original amounts as
opposed to the updated amounts. I can update ListBox1 without a
problem if I do not have the ListBox1_Click event, but this is
something I would like to have.

Thanks,
Mike.

 
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 Click Event BHatMJ Excel Discussion (Misc queries) 6 June 21st 07 09:34 PM
What event to detect click on UserForm ListBox? Don Wiss Excel Programming 1 August 26th 05 10:35 PM
Click event on listbox IanC Excel Programming 2 April 5th 05 07:05 AM
click event on listbox CStephenson Excel Programming 1 March 22nd 05 06:21 PM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


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