Combobox dropdown list doesn't go away

Posted on 2011-10-13
Last Modified: 2012-05-12
After I clear a combobox, and then select it, the dropdown list is the length of the last set of data in the list.  The dropdown image doesn't go away after clicking on the down arrow.  If I move my cursor to another window and back, it goes away.

Here is my code:
   'Load group combo box with group names
   gsSQL = "SELECT AVT_ClusterNo, AVT_Cluster FROM XrayAdvantage_Clusters "
   gsSQL = gsSQL & "WHERE AVT_MktNo = " & cboMkt.ItemData(cboMkt.ListIndex)
   gsSQL = gsSQL & "GROUP BY AVT_ClusterNO, AVT_Cluster "
   gsSQL = gsSQL & "ORDER BY AVT_Cluster"
   If rsTemp.State = adStateOpen Then rsTemp.Close
   rsTemp.Open gsSQL, cnXray, adOpenStatic, adLockReadOnly
   Do Until rsTemp.EOF
      cboGroup.AddItem rsTemp!AVT_Cluster
      cboGroup.ItemData(cboGroup.NewIndex) = rsTemp!AVT_ClusterNO
   Set rsTemp = Nothing

Question by:jsaacson
    LVL 11

    Expert Comment

    I'm trying to understand your question.  Please correct and clarify if I misunderstood.  Are there two questions here:

    1.  "After I clear a combobox, and then select it, the dropdown list is the length of the last set of data in the list."

    Are you saying here that when you clear and repopulate the combo box from a query data result set, that the visible element of the combo box that drops down stays the same length regardless of the number of elements in the list?  Do you have more than 8 items in the list?  That is normal.  I don't think you can change the number of rows that are displayed in a combo box on VB6.  

    Try this example.  Start a new form, and put a combo box and a button on the form.  Paste this code in the form module.

    Private Sub Command1_Click()
        Dim i As Integer
        Dim r As Integer
        r = CInt(Int(8 * Rnd(Time) + 1))
        For i = 1 To r
            Combo1.AddItem "Item " & Format(i, "00")
            Combo1.ItemData(Combo1.NewIndex) = i
        Next i
        MsgBox r & " items added to list."
    End Sub
    Private Sub Form_Load()
    End Sub

    Open in new window

    Notice it will place a random number of elements in the combo box when you press the button.  After you press the button, click the combo box drop down button and look at the list.  It adjusts based on the number of items in the list.

    Now, change the value 8 to something like 45, and run the program again.  Click the button to add items to the combo box again.  Anything over 8 items in the list will always show only a maximum of 8 entries in the list.

    2. "The dropdown image doesn't go away after clicking on the down arrow."

    This is puzzling, because I can't reproduce what you are describing.  Nothing I can do seems to keep the list under the drop down combo box visible.  Can you show a screenshot or further explanation to clarify what the
    problem is.  Or maybe even upload a small sample project that demonstrates the problem you are describing.

    Author Comment

    Here is what it looks like

    LVL 11

    Expert Comment

    (Sorry for the delay.)

    Oh, I see.  The is a refresh issue.  Based on what I saw here, I tried to recreate the form to see if it behaves the way you demonstrated.  Can you try my sample (attached) and see if it behaves incorrectly for you.  It did not exhibit the problem you showed for me.  I'm wondering if there is something else on the form or something with the elements directly below the combo box that is causing this.

    Try mine, and let me know what the two controls are directly below the combo - text or label, frame or box.

    Try my sample, then, if you can take your form, strip out the code and use something like the code I have in mine to populate the combo boxes with dummy data, and see if it still behaves that way.  And possibly upload just that form so I can try it on my system.  I think it either has to be something with the controls, or code on the form.

    This is VB6, right?  Not Access (There is a command in Access to pause screen refreshes that I could see causing this to happen.)  What about any 3rd party controls on the form? It looks like they are all standard controls, but I wanted to check that.

    Author Comment

    I don't see your sample.  
    LVL 11

    Expert Comment

    Sorry about that.  Here's the form file.  Can you upload a copy of your form without the code attached.

    Accepted Solution

    I am going to close this issue, as the problem only occurs when I am testing the program from visual basic.  Once I create the executable module and run from that, the problem goes away.  Thus it isn't important enough to figure out why it is happening.

    Thanks for your help
    LVL 11

    Expert Comment


    Author Closing Comment

    The problem goes away when running in production.  While there may be a solution to the problem, it is not worth the effort to continue researching and testing solutions.  Therefore, I am dropping the issue.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    How can this article save you time AND money?  In just a few minutes you may discover something you didn't know existed that is easy enough for you to fix yourself!
    Computer running slow? Taking forever to open a folder, documents, or any programs that you didn't have an issue with before? Here are a few steps to help speed it up. The programs mentioned below ALL have free versions, you can buy them if you w…
    The viewer will learn how to back up with the free utility from runtime software, DriveImageXML using Windows 8. Download DriveImageXML from Open folder where it was saved: Start installation by double clicking the install scrip…
    The viewer will learn how to download, install and use CrashPlan from on Windows 7. Open your browser and go to Click get started, it’s free then Click the Download CrashPlan button: Click save in Internet Explorer, the…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now