首页 文章

访问运行时错误3075

提问于
浏览
0

我无法运行以下报告 . 我一直得到运行时错误3075. reportText是表单上的文本框字段 . 该错误似乎在reportsearch字段中 .

Private Sub Command284_Click()

Dim reportsearch As String Dim reportText As String

如果是IsNull(Me.txtReport.Value)那么MsgBox“这个框必须连续一个关键字”Me.txtReport.SetFocus

否则reportText = Me.txtReport.Value

reportsearch = "SELECT * FROM NCECBVI WHERE ([Last Name] LIKE "“" & reportText & "”" OR ([First Name] LIKE "“" & reportText & "”"))"

DoCmd.OpenReport“NCECBVI-Report”,acPreview,reportsearch

万一

结束子

1 回答

  • 0

    OpenReport 命令的 WhereCondition 参数应该只包含条件本身,而不包含其他语法 . 将您的 reportsearch 分配更改为:

    reportsearch = "[Last Name] LIKE """ & reportText & """ OR [First Name] LIKE """ & reportText & """"
    

    此外,您在条件中使用 LIKE ,但您没有任何通配符 . 将 LIKE 更改为 = 或使用通配符获取包含输入字符串的匹配项:

    reportsearch = "[Last Name] LIKE ""*" & reportText & "*"" OR [First Name] LIKE ""*" & reportText & "*"""
    

相关问题