none
How to fix "Runtime error '438' object doesn't support this property or method" for activeX Combobox RRS feed

  • Question

  • Hi All,

    Last year we developed a simple excel based application having a combo box and button.

    On opening the excel sheet, we were filling the combo box with  project name from database, and on selection, we were giving end user to view selected project's other details from the database.

    Now from last month, on opening the this tool, we get the  below exception.

    The code snippet for filling the combobox is

                        

    ---------------------------

    Public Sub FillComboBox()
        Dim sStr As String
       Dim rs As New ADODB.Recordset


       sSQL = "Select Project .......From Project table."

       closeRS
       OpenDB
       rs.Open sSQL, sConnect, adOpenKeyset, adLockOptimistic


       With ActiveSheet.ComboBox1  <---Gets exception here
        .Clear
        Do
        .AddItem rs![Project]
        rs.MoveNext
        Loop Until rs.EOF
       End With

       Set rs = Nothing

    End Sub

    Please me help me to resolve this issue.


    Sonu88

    Thursday, November 24, 2016 5:02 PM

Answers

  • Hi Sonu888,

    I try to test your above mentioned code.

    as I don't have a database so I remove that part and simple assign the data from range and it worked.

    Sub demo()
     With ActiveSheet.ComboBox1
         .Clear
        .List = Worksheets("Sheet2").Range("A1:A5").Value
        .AddItem ("demo")
        End With
    
    End Sub
    

    so here I think that please check for your recordset.

    make sure it contains the value.

    please try to print the recordset data. so that we can know that code for recordset is correct and it contains the data too.

    I did not find any issue with code for assigning data to combobox1.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Sonu888 Wednesday, November 30, 2016 4:03 AM
    Friday, November 25, 2016 2:16 AM
    Moderator

All replies

  • Hi Sonu888,

    I try to test your above mentioned code.

    as I don't have a database so I remove that part and simple assign the data from range and it worked.

    Sub demo()
     With ActiveSheet.ComboBox1
         .Clear
        .List = Worksheets("Sheet2").Range("A1:A5").Value
        .AddItem ("demo")
        End With
    
    End Sub
    

    so here I think that please check for your recordset.

    make sure it contains the value.

    please try to print the recordset data. so that we can know that code for recordset is correct and it contains the data too.

    I did not find any issue with code for assigning data to combobox1.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Sonu888 Wednesday, November 30, 2016 4:03 AM
    Friday, November 25, 2016 2:16 AM
    Moderator
  • Hi Sonu888,

    did your issue resolved?

    we did not got any response from you after you had posted this issue.

    if your issue is solved then please try to update the status of this thread.

    so that we can know about that and we can close this thread if it is solved.

    if your issue is still exist then please refer my earlier suggestion and check it.

    as I had informed you that there is no error on the below mentioned line.

     With ActiveSheet.ComboBox1  

    as you also mentioned that the same code was working fine before some time.

    so it is possible that this error is occur due to some other reasons.

    I recommend you to also check below mentioned line

       rs.Open sSQL, sConnect, adOpenKeyset, adLockOptimistic
    
    

    let me know if you had installed any office, windows related updates or did some change in any drivers.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 28, 2016 5:28 AM
    Moderator