这里我们说一下利用命令按钮或导航控件控制组合框选择值:
主要是利用组合框和列表框ListIndex和ListCount属性完成,关键是要让组合框或列表框的控件获得焦点方可进行设置这两个值,获得焦点的方法有两种:Me.Combo3.SetFocus 和 DoCmd.GoToControl "Combo3"
具体的源码:
Private Sub Command29_Click()
On Error Resume Next
'最前
Me.Combo3.SetFocus
Me.Combo3.ListIndex = 0
Me.Recalc
End Sub
Private Sub Command30_Click()
On Error Resume Next
'前一
Me.Combo3.SetFocus
Me.Combo3.ListIndex = Me.Combo3.ListIndex - 1
End Sub
Private Sub Command31_Click()
On Error Resume Next
'后一
DoCmd.GoToControl "Combo3"
Me.Combo3.ListIndex = Me.Combo3.ListIndex + 1
End Sub
Private Sub Command32_Click()
On Error Resume Next
'最后
DoCmd.GoToControl "Combo3"
Me.Combo3.ListIndex = Me.Combo3.ListCount - 1
End Sub