不明白为什么这个查询会导致 Access 崩溃

Don't understand why this query crashes Access

我有一个包含嵌套查询的查询,如下所示:

select table1.name, table1.address 
       from table1 
       where table1.year=[forms]![form1]![year] 
             and table1.name not in 
             (select table2.name 
                     from table2 
                     where table2.year=[forms]![form1]![year])

这每次都会导致 Access 崩溃。是否在做不允许的事情?

我能够通过使用 VBA 构建我的查询来让它工作。

本质上我写了一个设置 rs=db.OpenRecordset("my subquery")

的函数

然后遍历 rs,并将其附加到一个字符串,如下所示:

string=""
rs.MoveFirst
Do Until rs.EOF
string=string & "'" & rs.Fields(0) & "', "
rs.MoveNext
loop
if string <> "" then string=Left(string,len(string)-2)

最后:

strSQL="select table1.name, table1.address from table1 where table1.year=forms]![form1]![year] and table1.name not in (" & string & ")"

然后在我的更新后活动中

me![subform].form.Recordsource=myfunction()

现在一切正常