Forum Discussion

guitar713's avatar
guitar713
Brass Contributor
Mar 04, 2024

Combo Boxes not displaying Data

I have 2 forms.  The first form has drop down boxes and they work well..    I have a button in call and open the second form.  The second form opens and the first form remains open, which is what I want; however, the combo box on the second form is not displaying the data.  I have searched for answers and found none.  Can anyone help me get the data to show on the second form?  Yes, the second form is linked to the excel sheet just as the first form is.  Followed same procedure as the first form box.  Please help, this is driving me crazy.  Thanks much.

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    guitar713 

    It sounds like the issue might be related to how the combo box in the second form is populated with data. Here are a few steps you can take to troubleshoot and fix the issue:

    1. Check Data Source: Ensure that the combo box in the second form is linked to the correct data source in your Excel sheet. Double-check the range of cells or named range that you have specified as the data source for the combo box.
    2. Verify Data Range: Make sure that the data range specified for the combo box includes the correct data and that there are no empty cells or errors within the range.
    3. Refresh Data: If the data in your Excel sheet has been updated since you opened the second form, you may need to refresh the data source for the combo box. You can do this programmatically using VBA code or manually by closing and reopening the form.
    4. Ensure Visibility: Check the properties of the combo box in the second form to ensure that it is set to be visible. Sometimes, if the visibility property is accidentally set to false, the combo box may not display any data.
    5. Debugging: Use VBA debugging tools to check if there are any errors occurring when populating the combo box with data. You can set breakpoints in your code and step through it to see if there are any issues.
    6. Recreate Combo Box: If all else fails, try deleting the combo box in the second form and recreating it from scratch. Sometimes, there may be hidden issues with the combo box properties that are difficult to identify.

    If you're still experiencing issues after trying these steps, please provide more details about how the combo box is populated and any relevant VBA code that you're using. This will help in providing a more targeted solution to the problem. The text was created with the help of AI

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    Was the answer useful? Mark as best response and like it!

    This will help all forum participants.

    • guitar713's avatar
      guitar713
      Brass Contributor

      NikolinoDE   Thank you for replying.  I have tried all the above.  Still no luck.  I was wondering if it has to do with a bug in software?  In that you can't have 2 forms open at once?  The strange thing is, I tested the combo box by moving it to the first form, and it works fine.  when I move it to the second form, I don't see the data.  Any other ideas?  Thanks.

      • djclements's avatar
        djclements
        Bronze Contributor

        guitar713 Having two userforms open at once shouldn't be a problem. Glitches can occur, though, especially with Excel for MS365. How exactly are you populating the combo box? Did you hard code the worksheet range directly in the RowSource property of the combo box? Did you define a name for the worksheet range, as shown in the example below?

         

        ComboBox RowSource Property

         

        Alternatively, you can also try leaving the RowSource property blank, then populate it on the fly in the UserForm_Initialize procedure. For example:

         

        Private Sub UserForm_Initialize()
            Me.ComboBox1.RowSource = "lstStatus"
        End Sub

         

        Or, by looping through the items in the range:

         

        Private Sub UserForm_Initialize()
            Dim rg As Range, i As Long
            Set rg = Range("lstStatus")
            For i = 1 To rg.Rows.Count
                Me.ComboBox1.AddItem rg.Cells(i, 1).Value
            Next i
        End Sub

         

        These are just a few basic examples. I've tested them all with two simple userforms (shown in the screenshot above) and did not have any issues. If you are still unable to get it to work, please consider sharing more details, such as the code you are using in the each of the userforms, especially the code that opens the second userform, as well as any code currently being used in the UserForm_Initialize procedure of the second userform.

Resources