简体   繁体   English

MS Access VBA组合框打开一个对话框,而不是从窗体中获取组合框值

[英]MS Access VBA Combo Box opens a dialog instead of taking the combo box value from the form

I want to filter a list of records by a certain date, which the user selects from a Combo Box. 我想按特定日期筛选记录列表,该日期由用户从组合框中选择。

Here is the code that I have to apply a filter when the value of the combo box changes. 这是当组合框的值更改时必须应用过滤器的代码。

Private Sub cboSelectByDate_Change()
    DoCmd.ApplyFilter , "[Delivery Date] = Me.cboSelectByDate"
`End Sub`

However when the combo box is changed, a dialog box titled "Enter Parameter Value" appears asking for a value for Me.cboSelectByDate 但是,更改组合框时,会出现一个标题为“输入参数值”的对话框,要求Me.cboSelectByDate的值。

How can I make sure Access reads the currently selected value of the combo box instead of opening this dialog? 如何确保Access读取组合框的当前选定值,而不是打开此对话框?

I was using the wrong syntax for referencing the comboBox. 我使用了错误的语法来引用comboBox。

Private Sub cboSelectByDate_Change()
    DoCmd.ApplyFilter , "[Delivery Date] = Forms!frmDeliveries!cboSelectByDate"
End Sub

Has the desired result 有理想的结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM