如何关闭组合框中的下拉列表在VBA中的鼠标移动事件?

时间:2017-05-16 09:09:41

标签: vba combobox

我正在Access中开发用户表单。当鼠标在组合框上时,我有这个代码打开下拉菜单:

    Private Sub cmbx_ID_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.cmbx_ID.SetFocus
    Me.cmbx_ID.Dropdown
End Sub

但是当鼠标离开组合框时我想要关闭下拉菜单(现在要关闭表格,他应该在下拉菜单中选择一个项目或点击表格)。我发现当鼠标在此按钮上时,我可以创建一个按钮并关闭表单:

    Private Sub Frame1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    CommandButton1.SetFocus
    SendKeys "{esc}", True    
End Sub

但这不是我想要的。

0 个答案:

没有答案