(错误 3071)访问

发布于 2024-11-06 12:08:40 字数 476 浏览 1 评论 0原文

我试图通过检查课程表中的教员 ID 和课程 ID 来搜索课程 ID。它是一个简单的查询,但启动时我收到一个

(此表达式键入不正确,或者它太复杂而无法计算。例如,数字表达式可能包含太多复杂的元素。尝试通过将表达式的一部分分配给来简化表达式(错误 3071)

我使用的 VB 脚本如下所示。

Private Sub Course_ID_DblClick(Cancel As Integer)

Dim x As Integer

Dim y As String

Dim z As Integer

x = Me.Faculty_ID.Value

Me.Course_ID.RowSource = "SELECT Course.[Course ID] FROM Course WHERE Course.[Course Name]=['Course']AND Course.[Faculty ID]='" & x & "'"

End Sub

I'm trying to search for the Course ID by checking the the faculty ID and Course ID in my Course table. Its a simple query but when launched I receive a

(This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables. (Error 3071)

The VB script I'm using looks like this.

Private Sub Course_ID_DblClick(Cancel As Integer)

Dim x As Integer

Dim y As String

Dim z As Integer

x = Me.Faculty_ID.Value

Me.Course_ID.RowSource = "SELECT Course.[Course ID] FROM Course WHERE Course.[Course Name]=['Course']AND Course.[Faculty ID]='" & x & "'"

End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北方的韩爷 2024-11-13 12:08:40

我认为您收到此消息是因为您在对象名称中使用了错误的分隔符和令人困惑的术语(其中字段内容“course”和表名称 [course] 相同。

我猜您的数据源是 ms-access 数据库。然后您应该使用“(双引号)作为文本的值分隔符(您必须将表达式内的符号加倍),而对于数字则不使用任何内容。您的选择指令可能如下所示:

"SELECT Course.[Course ID] FROM Course WHERE Course.[CourseName]=[""Course""] AND Course[FacultyID]=" & x

添加 'debug.print Me.Course_ID.RowSource ' 检查最终的字符串应如下所示:

SELECT Course.[Course ID] FROM Course WHERE Course.[CourseName]=["Course"] AND Course[FacultyID]= 3

I think you are getting this message because you are using wrong delimiters and confusing terminology in object names (where field content 'course' and table name [course] are the same.

I guess your datasource is an ms-access database. You should then use the " (double quote) as value separator (you'll have to double the sign inside the expression) for text, and nothing for numbers. your select instruction could then look like:

"SELECT Course.[Course ID] FROM Course WHERE Course.[CourseName]=[""Course""] AND Course[FacultyID]=" & x

Add a 'debug.print Me.Course_ID.RowSource' to check the final string that should look like:

SELECT Course.[Course ID] FROM Course WHERE Course.[CourseName]=["Course"] AND Course[FacultyID]= 3
只为一人 2024-11-13 12:08:40

字符串文字周围不应有括号:

Me.Course_ID.RowSource = "SELECT Course.[Course ID] FROM Course WHERE Course.[Course Name]='xyz' AND ...

此外,您可以在访问查询中使用单引号或双引号作为字符串分隔符。

There should be no brackets around your string literals:

Me.Course_ID.RowSource = "SELECT Course.[Course ID] FROM Course WHERE Course.[Course Name]='xyz' AND ...

Also, you can use either single or double quotes as string delimiters in an access query.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文