Skip to Content
author's profile photo Former Member
Former Member

UI: Clearing items from a combobox item in a matrix

How do you clear all the items out of a combo box in a matrix?

For "normal" comboboxes on a form I've been using the following code:

Set cbo = oForm.Items("cbo").Specific

If (Not cbo Is Nothing) Then

Do While cbo.ValidValues.Count > 0

Call cbo.ValidValues.Remove(0, psk_Index)

Loop

End If

But if I use the same code for a combo box in a matrix I get the following error:

Runtime Error "-10"

Am I missing something? Is there a better way of removing items from a combobox?

Thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Apr 14, 2004 at 08:32 AM

    Hi Simon

    An old developer hint is: Delete all items of a list by deleting the last item first, and then stepping back to the top of the list removing the first item last.

    Perhaps this old hint solves your problem too? Code could look like this (not tested):

    dim i as Long

    For i = cbo.ValidValues.Cont-1 To 0 Step -1

    cbo.ValidValues.Remove(i, psk_Index)

    next i

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.