Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox click event not firing

Status
Not open for further replies.

JTBorton

Technical User
Jun 9, 2008
345
DE
Excel 2010
I have a list box on a form to display various information. When the user clicks on an item, the form should load and display the information corresponding to the selected item. I recently changed the listbox MultiSelect property to frmMultiSelectExtended, so that the user can delete several items from the list at the same time. After doing this, the click event will no longer fire at all. I placed a stop point on the first line of code, but it never even runs. Is it normal for the click event to no longer respond when the multiselect property is set to something other than frmMultiSelectSingle?

-Joshua
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
 



Please post your code!

The code that uses the listbox selection(s). Don't you think that that may be a relevant part of the issue?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
This control is on a form that has several multipage controls layered into the pages of one large multipage control.

To help avoid confusion among the controls, I am using the standard 3-letter prefix followed by an additional 4-letter section abbreviation. The abbrv 'FJDC' indicates that this control is located on the Daily Consumption page of the Food Journal multipage control.

Variable types with the fdb prefix are user-defined structures and enumerations.

Code:
Private Sub lstFJDCEaten_Click()
    Dim strType         As String
    Dim intEntryID      As Integer
    Dim intFoodID       As Integer
    Dim intRecipeID     As Integer
    Dim udtFoodItem     As fdbFoodItemData
    Dim udtRcpData      As fdbRecipeData
    Dim udtRcpItems()   As fdbRecipeComponentData
    Dim udtRcpNutr      As fdbNutritionalInfo
    
    If blnLoadFJDCEaten = True Then: Exit Sub
    With lstFJDCEaten
        If .ListCount < 1 Or .ListIndex < 0 Then
            cmdFJDCViewRecipe.Enabled = False
            cmdFJDCUpdateItem.Enabled = False
            Exit Sub
        End If
        Call ClearFJDCItemData
        strType = .List(.ListIndex, 2)
        intEntryID = .Value
        Select Case LCase(strType)
            Case "food item"
                cmdFJDCViewRecipe.Enabled = False
                intFoodID = ItemLookup(wksFoodJournal, intEntryID, "FoodID")
                udtFoodItem = GetFoodItemData(intFoodID)
                Call LoadFJDCFoodItem(intEntryID, udtFoodItem)
            Case "recipe"
                cmdFJDCViewRecipe.Enabled = True
                intRecipeID = ItemLookup(wksFoodJournal, intEntryID, "RecipeID")
                udtRcpData = GetRcpData(intRecipeID)
                udtRcpItems = GetRcpComponents(intRecipeID)
                udtRcpNutr = CalcRecipeNutrInfo(udtRcpData, udtRcpItems)
                Call LoadFJDCRcpItem(intEntryID, udtRcpData, udtRcpNutr)
            Case Else
                Exit Sub
        End Select
        fraFJDCItemData.Enabled = True
        cmdFJDCUpdateItem.Enabled = True
    End With
End Sub

The procedure executes flawlessly when lstFJDCEaten multiselect property is set to frmMultiSelectSingle, and does not execute at all when the property is set to frmMultiSelectExtended. I already understand that it would have some issues if more than one item were selected. That is what I wanted to code, which is when I learned that it was not executing at all.

-Joshua
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
 
consider the change event when working with a multi select.
 
That's so simple. Why didn't I think of that? I feel like a retard.

-Joshua
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top