在Excel VBA子系统中读取变量DAO.QueryDef

在Excel VBA子系统中读取变量DAO.QueryDef,excel,vba,Excel,Vba,是否可以将Dao.DataBase作为通过子数据库传递的参数 Public Sub FillInData(InfoArray() As Variant, qdf2 As DAO.QueryDef, k As Integer, rec_set_fill1 As Recordset, rec_set_fill As Recordset, DataBase As DAO.DataBase, TheId As Long, Weekly_Working As Integer) With

是否可以将Dao.DataBase作为通过子数据库传递的参数

Public Sub FillInData(InfoArray() As Variant, qdf2 As DAO.QueryDef, k As Integer, rec_set_fill1 As Recordset, rec_set_fill As Recordset, DataBase As DAO.DataBase, TheId As Long, Weekly_Working As Integer)
         With qdf2

问题是它给了我一个错误,在这个集合中找不到项,所以我假设它没有从Dao.Database或其他东西中读取。如果您使用CreateQueryDef创建,并且名称为空字符串,它不会附加到querydefs集合中,因此“在集合中找不到项”。给它起个名字,它应该存在足够长的时间才能通过。

您确定注册了正确的DAO库吗?DAO3.51适用于我,但我在使用DAO3.6时出现了一个错误-但这可能只是我的设置。我已将SQL\u查询设置为某些字符串,并将其设置为Set qdf=Dbse.CreateQueryDef(vbNullString,SQL\u query),但这在FillInData子文件中不返回任何内容