VBA code to clear data from combo box

If you want to clear data from combo box or list box, use the following vba code:

Combo0.RowSource=""
or
List0.RowSource=""

The example below shows you how  to clear data from combo box before adding the new data. When the form loads, the data in the combo box are cleared before the data are populated in to the combo box again.

Private Sub Form_Load()

  Combo0.RowSource = ""
  Combo0.RowSourceType = "Table/Query"
'Retrieve sex data from tblStudent into combo0
  Combo0.RowSource = "Select sex from tblStudent"

End Sub


Posted by: Yako | post date: 01-04-2013 | Subject: VBA for MS Access




    This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
    C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.