我正在运行Access 2016,我正在尝试从查询中获取一些记录。我是一个Access noob,我正在创建一个数据库。 当我运行以下代码时,我得到错误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语句错了,但我看不出问题。错误的来源是否在其他地方?
这是我得到的错误陈述:
有谁能告诉我如何解决这个问题?或者问题的原因是什么?