vba 在 Access 表单中过滤
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11022729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Filter in Access form
提问by Ish
I have a form and I want it to be filtered just after it loads.
我有一个表单,我希望它在加载后立即被过滤。
After I click on the form it should be able to load by filtering specific data. I want it to filter by Program Nam and Year.
单击表单后,它应该能够通过过滤特定数据来加载。我希望它按 Program Nam 和 Year 进行过滤。
I have tried the following code but I keep getting syntax errors:
我尝试了以下代码,但不断收到语法错误:
Private Sub Form_Load()
Combo5.Value = Form_0_Cover.Combo0
Combo7.Value = Form_0_Cover.Combo2
'Me.Filter = "[Program_Name]=" & Me.Combo7 & " AND [Budget_Year]='" & Me.Combo5 & ""
End Sub
I am not sure what the problem seems to be. I keep getting syntax error.
我不确定问题似乎是什么。我不断收到语法错误。
采纳答案by Fionnuala
Try:
尝试:
Me.Filter = "[Program_Name]='" & Me.Combo7 & "' AND [Budget_Year]=" & Me.Combo5
I suspect that program name is text and budget year is numeric. It is possible that the program name combo has an id as the bound column, in which case things might get a little more difficult, probably:
我怀疑程序名称是文本,预算年份是数字。程序名称组合可能有一个 id 作为绑定列,在这种情况下事情可能会变得更加困难,可能是:
Me.Filter = "[Program_ID]=" & Me.Combo7 & " AND [Budget_Year]=" & Me.Combo5