- Joined
- Jan 17, 2012
- Messages
- 4
- Reaction score
- 0
I have a listbox in Excel which I am populating with a set of 8 columns from a spreadsheet. There are potentially a few hundred entries, so there is also some selection logic on the form.
I use an external procedure (ThisWorkbook.LoadEventList) which takes the form as a parameter, so that I can move all the selection/loading logic outside the event handler for lstEventList_Click.
The load procedure works very nicely, but the list itself only displays once. Here is the code that is in the event handler (summarized):
(Just in case - the form is called newfrmEventList, The procedure to load the list is ThisWorkbook.LoadEventList(Formname) and the procedure to load the selected entry - using a different form) is THisWorkbook.LoadEventIntoForm(Formname,EventID)
So - referring to the code -
(1) if I don't call LoadEventList the list is visible when I return from showing the detail event, but even though the selected row changes visual appearance, no events are fired (no lstEventList_Click in particular)
(2) if I do call LoadEventList, the return leaves the listbox totally empty, and again, no events are fired.
Either way, the selection logic (which also loads the eventlist) works fine, and the list is recreated (via LoadEventList).
I can't figure this out - I have a small test system where the same concept (selecting on one form and displaying on another) works fine.
Any ideas?
Tony
I use an external procedure (ThisWorkbook.LoadEventList) which takes the form as a parameter, so that I can move all the selection/loading logic outside the event handler for lstEventList_Click.
The load procedure works very nicely, but the list itself only displays once. Here is the code that is in the event handler (summarized):
Code:
Private Sub lstEventList_Click()
Dim ThisEntry As Integer
Dim ThisEventID As String
' Get the data we need to load the selected event
ThisEntry = Me.lstEventList.ListIndex
ThisEventID = Me.lstEventList.List(ThisEntry, 0)
Load newfrmEvents
newfrmEvents.Caption = "Event Detail Data"
ThisWorkbook.LoadEventIntoForm newfrmEvents, ThisEventID
Me.Hide
newfrmEvents.Show
Unload newfrmEvents
' The list will get reconstituted as part of the form activation
'ThisWorkbook.LoadEventList Me
Me.Show
End Sub
So - referring to the code -
(1) if I don't call LoadEventList the list is visible when I return from showing the detail event, but even though the selected row changes visual appearance, no events are fired (no lstEventList_Click in particular)
(2) if I do call LoadEventList, the return leaves the listbox totally empty, and again, no events are fired.
Either way, the selection logic (which also loads the eventlist) works fine, and the list is recreated (via LoadEventList).
I can't figure this out - I have a small test system where the same concept (selecting on one form and displaying on another) works fine.
Any ideas?
Tony