MS Access Multi-select Combo Box Select All/None

前端 未结 2 1705
耶瑟儿~
耶瑟儿~ 2021-01-03 12:26

I have a combo box on a form that is linked to a SharePoint field, the combo box populates correctly however I am having difficulty trying to add VBA code to select all of t

相关标签:
2条回答
  • 2021-01-03 13:09

    http://msdn.microsoft.com/en-us/library/office/aa140084(v=office.10).aspx I beleive this covers what you are asking

    0 讨论(0)
  • 2021-01-03 13:19

    After a ton of searching and trial and error I figured it out.

    To unselect all of the check boxes it is

    cmbBox1.Value = Array()
    

    So with this information I figured that to select items they have to be in an array. Creating an array with all of the items that are in the combo box and then setting the combo box equal to the array will select all of the items.

    I used a basic loop to set each element of the array

    Dim SelVals(), i
    ReDim SelVals(0 to cmbBox1.ListCount - 1)
    For i = 0 to cmbBox1.ListCount - 1
         SelVals(i) = cmbBox1.Column(1,i)
    Next i
    cmbBox1.Value = SelVals
    

    Obviously then you aren't limited to only using the entire contents - you could assign any array and those would be the values selected.

    0 讨论(0)
提交回复
热议问题