Ms access 2016 访问运行时错误3075

Ms access 2016 访问运行时错误3075,ms-access-2016,Ms Access 2016,我无法运行以下报告。我一直收到运行时错误3075。reportText是表单上的文本框字段。错误似乎出现在reportsearch字段中 专用子命令284_Click() Dim reportsearch作为字符串 将报表文本设置为字符串 如果为null(Me.txtReport.Value),则 MsgBox“此框必须包含关键字” Me.txtReport.SetFocus 否则 reportText=Me.txtReport.Value reportsearch=“从NCECBVI中选择*,

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

专用子命令284_Click()

Dim reportsearch作为字符串 将报表文本设置为字符串

如果为null(Me.txtReport.Value),则 MsgBox“此框必须包含关键字” Me.txtReport.SetFocus

否则 reportText=Me.txtReport.Value

reportsearch=“从NCECBVI中选择*,其中([姓氏]类似于“”&reportText&“”,或([名字]类似于“”&reportText&“”)

DoCmd.OpenReport“NCECBVI报告”,acPreview,reportsearch

如果结束


End Sub

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

reportsearch = "[Last Name] LIKE """ & reportText & """ OR [First Name] LIKE """ & reportText & """"
此外,您在条件中使用了类似于的
,但没有任何通配符。将
更改为
=
,或使用通配符获取包含输入字符串的匹配项:

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