简体   繁体   English

编译错误:语法错误MS Access 2013

[英]Compile Error: Syntax Error MS Access 2013

I'm fairly new to Access and am attempting to make a searchable form, where the the form returns all entrees that meet all of the criteria in several text boxes. 我对Access相当陌生,正在尝试制作一个可搜索的表单,该表单在几个文本框中返回满足所有条件的所有主菜。 I found a code online that should do exactly what I need 我在网上找到了可以完全满足我需要的代码

http://www.allenbrowne.com/ser-62.html http://www.allenbrowne.com/ser-62.html

http://www.allenbrowne.com/ser-62code.html http://www.allenbrowne.com/ser-62code.html

But I am running into errors when I try to run in for myself. 但是,当我尝试自己跑步时,我遇到了错误。 I am currently just trying to link up one textbox before adding on several others. 我目前只是在尝试添加多个文本框之前先链接一个文本框。 Here is my code thus far: 到目前为止,这是我的代码:

Private Sub SearchAll_Click()

If Not IsNull(Me.txtCityCounty) Then
    strWhere = strWhere & "([City/County] Like "" * " & Me.txtCityCounty & " * """)"

    End If

End Sub

When I try to run it, I get "Compile Error: Syntax Error" and the line "Private Sub SearchAll_Click()" is highlighted in yellow. 当我尝试运行它时,出现“编译错误:语法错误”,并且“ Private Sub SearchAll_Click()”行以黄色突出显示。

If it helps: "SearchAll" is my button, "txtCityCounty" is the textbox, "City/County" is the field name. 如果有帮助:“ SearchAll”是我的按钮,“ txtCityCounty”是文本框,“ City / County”是字段名称。 I'm currently using Access 2013. 我目前正在使用Access 2013。

Any and all help is much appreciated, thank you. 非常感谢您的任何帮助。

The line in your code which says 您的代码行中写着

strWhere = strWhere & "([City/County] Like "" * " & Me.txtCityCounty & " * """)"

should be shown in red, indicating that it is the line where the syntax error was detected. 应该以红色显示,表明这是检测到语法错误的行。

If you look at that line you will notice that your double-quotation marks are not matched. 如果您查看该行,您会发现双引号不匹配。 I suspect you intended it to be: 我怀疑您打算这样做:

strWhere = strWhere & "([City/County] Like "" * " & Me.txtCityCounty & " * "")"

or, maybe, just 或者,也许

strWhere = strWhere & "([City/County] Like ""*" & Me.txtCityCounty.Text & "*"")"

depending on how you want the wildcard to work. 取决于您希望通配符的工作方式。 (I believe your current test will be for a space, followed by any number of characters, followed by a space, followed by your City/County textbox value, followed by a space, followed by any number of characters, followed by a space.) (我相信您当前的测试将针对空格,任意数量的字符,空格,城市/县文本框值,空格,任意数量的字符,空格。 )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM