Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access 如何从SELECT语句创建记录集(错误:集合中找不到项)_Ms Access_Vba - Fatal编程技术网

Ms access 如何从SELECT语句创建记录集(错误:集合中找不到项)

Ms access 如何从SELECT语句创建记录集(错误:集合中找不到项),ms-access,vba,Ms Access,Vba,我试图用SELECT语句打开记录集,但一直收到以下错误消息:在集合中找不到运行时错误3265项 我正在Access 2007表单中的字段中对lostFocus事件运行此代码 这是我的密码: Dim myDB As Database Dim myREC As DAO.Recordset Dim strRegionsMsg, boolRegionMsg Dim strQuery Set myDB = CurrentDb strQuery = "Sel

我试图用SELECT语句打开记录集,但一直收到以下错误消息:在集合中找不到运行时错误3265项

我正在Access 2007表单中的字段中对lostFocus事件运行此代码

这是我的密码:

    Dim myDB As Database
    Dim myREC As DAO.Recordset
    Dim strRegionsMsg, boolRegionMsg
    Dim strQuery
    Set myDB = CurrentDb

    strQuery = "Select * FROM RTA;"
    Set myREC = myDB!Execute(strQuery)
    'Set myREC = myDB!Recordsets(strQuery)
正如你所看到的,我尝试了反冲,也遇到了同样的问题。此外,我还使用Access的查询生成器运行了我的查询,它可以正常工作

我是不是遗漏了什么?

试试这个:

Dim myDB As Database
Dim myREC As DAO.Recordset
Dim strRegionsMsg, boolRegionMsg
Dim strQuery
Set myDB = CurrentDb

strQuery = "Select * FROM [RTA]"
Set myREC = myDB.OpenRecordset(strQuery)

它起作用了。谢谢但是openRecordset、Execute和RecordSetExecute之间的区别是用于操作查询,而不是Access DAO中的select查询。而且,记录集是打开的记录集的集合。显然,没有名为“Select*FROM RTA”的对象再次感谢您的精确性