vba doCmd.openreport where 子句提示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3251980/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 11:53:02  来源:igfitidea点击:

doCmd.openreport where clause prompting

ms-accessvbaaccess-vba

提问by misguided

I have a simple piece of code written to open a report.

我编写了一段简单的代码来打开报告。

  Private Sub FormButton_Enter()
    Dim strwhere As String
    strwhere = Me.FormText
    DoCmd.Openreport "rtpname",acViewPreview,,"ColumnName=" & strwhere 
  End Sub

I am getting two popups , even though i pass the filter criteria from the form. Please advice.

我收到了两个弹出窗口,即使我通过了表单中的过滤条件。请指教。

回答by BenV

One potential cause is that ColumnNameis non-numeric and you are not putting the value in quotes. If this the problem then the fix is:

一个潜在的原因是它ColumnName不是数字,并且您没有将值放在引号中。如果这是问题,那么修复方法是:

 DoCmd.Openreport "rtpname",acViewPreview,,"ColumnName='" & strwhere & "'"