none
Combo Box clear RRS feed

  • Question

  • I have a form with 32 combo boxes names cb1 to cb32 after entering the form I need to reset the form prior to the next entry

    i have tried many variants but keep getting error 438

    Dim c_d As Integer
    Dim x_dc As Integer
    For c_d = 1 To 32 Step 1
        x_dc = "cb" & c_d
        MsgBox (x_dc)
        exp_ip.Controls(c_d).ClearContents
     next.

    i have tried clear, text="",value="",list range , and many more

    any ideas

    Thanks for reading

    Sunday, May 17, 2015 4:14 PM

All replies

  • Lux Sparks,

    when you say form, it isn't totally clear what you mean.  I will assume you mean a userform.

    So I created a userform named Userform1 and put two activeX comboboxes on it (named CB1 and CB2).  I then put on a command button with this code:

    Private Sub CommandButton1_Click()
    For i = 1 To 2
      UserForm1.Controls("CB" & i).ListIndex = -1
    Next
    End Sub

    I show the userform, make selections in the comboboxes and then click the command button and the selections are cleared. 

    Does that fit what you are trying to do?


    -- Regards, Tom Ogilvy Note: When you get an answer to your question, please mark it as the answer so others may know the question is answered.


    Sunday, May 17, 2015 6:01 PM
  • Hi Tom

    thanks for the prompt reply you are correct in that i'm using a userform and unfortunately i have already tried "listindex" and got an run time error 2147483645 (800000003)

    I'm just thinking is it a Mac Office issue with the combobox. i'm able to clear on the same userform all the textboxes and labels.

    Thanks again

    Monday, May 18, 2015 9:52 AM
  • Hi Lux,

    You said that “I'm just thinking is it a Mac Office issue with the combobox”, do you using the excel in Mac? If so, the Office for Mac forum is the better place for this issue, I suggest that you could post it to that forum, after that please post the link here, which will benefit others who has the similar issue.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 19, 2015 3:31 AM
    Moderator