2

我正在运行 Access 2016,我正在尝试从查询中获取一些记录。我是一个 Access 菜鸟,我正在制作一个数据库。当我运行以下代码时,我得到错误 3075,它说操作员不存在,问题是,当我将 SQL 代码粘贴到访问查询中时,它运行得很好,所以我看不到问题

    Sub DOthings()

Dim i As Integer
Dim array1() As Variant
Dim array2() As Variant

Dim daDb As DAO.Database
Set daDb = CurrentDb


'' getting temp vars first
Dim vend As String
vend = CStr([TempVars]![temp1]) '' I get these TEMP vars from the access application

Dim loc As String
loc = CStr([TempVars]![temp2])

MsgBox ("Vendor is: " & vend & " And Location is: " & loc)
'setting SQL statement
Dim qry As String 'SQL STATEMENT FOR QUERY
qry = "SELECT [Table1].ScanID, [Table2].FieldV, [Table1].[FieldA], [Table1].[FieldE], (([Table1]![FieldE])/([Table1]![FieldA])) AS V, [Table1].[QR Code], [Table3].[Selected?], [Table3].[Location Recieved], [Table3].[Travel Notes] FROM ([Table2] INNER JOIN [Table1] ON [Table2].BatchID = [Table1].BatchID) INNER JOIN [Table3] ON [Table1].ScanID = [Table3].Scan_ID **WHERE ((([Table2].FieldV) = " & vend & ") And (([Table3].[Location Recieved]) = " & loc & ") And (([Table3].[Date Shipped]) Is Null)) ORDER BY (([Table1]![fieldE])/([Table1]![FieldA])) DESC;**"
Dim daQdf As DAO.QueryDef 'First Query to find and SELECT the actual datapoints."
Set daQdf = daDb.CreateQueryDef(qname, qry)

Dim daRs As DAO.Recordset 'Getting the recordset Setup
Set daRs = daQdf.OpenRecordset(qname, Dynaset)

所以我得到的错误基本上是说我的 Where 语句是错误的,但我看不到问题所在。错误的根源在其他地方吗?

这是我得到的错误声明:

在此处输入图像描述

谁能告诉我如何解决这个问题?或者问题的原因是什么?

4

0 回答 0