In my MS Access project I need to set selected index of a combobox using VBA. I used the syntax below to select the first item.
Application.CommandBars("MainMenu").Controls("Country").SelectedValue = "US"
After use the above syntax I get the error ”Object does not support this property or method”
I need help to setting the combo box selected item
Me.fromDate = Me.fromDate.ItemData(0) 'Get first item and set that to the selected value
Me.toDate = Me.toDate.ItemData(Me.toDate.ListCount - 1) 'Get last item and set that to the selected value
您也可以直接设置所需的选定值:
Me!cboTest = "US"
Hope Bellow syntax solve problem
Just use the combo.ListIndex=ComboBoxIndex
In Access 2013 ListIndex is readonly. You can change the value of the combobox as suggested above. When you do so, the ListIndex is modified by Access but it won't point to the row you used. I've not found any information on how to select a row and have the ListIndex point to that row after selection. The only solution I can come up with is to keep static variables around that I maintain to keep track of what is really selected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.