访问运行时错误3075

时间:2018-04-26 15:26:19

标签: ms-access-2016

我无法运行以下报告。我一直得到运行时错误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([姓] LIKE"" "& reportText&" &# 34;"或([名字]喜欢"" "& reportText&" "") )"

DoCmd.OpenReport" NCECBVI-Report",acPreview ,, reportsearch

结束如果

End Sub

1 个答案:

答案 0 :(得分:0)

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

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

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

reportsearch = "[Last Name] LIKE ""*" & reportText & "*"" OR [First Name] LIKE ""*" & reportText & "*"""
相关问题