How to remove all items from a drop-down list in Access 2007?


I have a referesh condition , after which the items in the drop down list of Access 2007 form gets altered.

For i = LBound(ddlRequestorNM) To UBound(ddlRequestorNM)
ddlRequestorNM.RemoveItem (i)

The above code is erroring with Array out of index. I came to know that everytime , the item is deleted, the array index gets out of bounds. Some one pls help to delete all the items at once.

You should delete the items in reverse order:

For i = UBound(ddlRequestorNM) To LBound(ddlRequestorNM) Step -1

otherwise they are re-indexed every time one is deleted, eventually trying to refer to an item that doesn't exist.

For a standard ComboBox you can clear all items using ddlRequestorNM.RowSource = "".