通过 SQL 引用 VBA 记录集
我想通过 SQL FROM 语句引用记录集。例子。
我有一个名为 RS 的记录集。我想做的是下面的VBA。
SELECT * FROM RS
有办法吗?
I'd like to make a reference to a recordset via SQL FROM statement. Example.
I have a Recordset called RS. What I want to do is the following, in VBA.
SELECT * FROM RS
Is there a way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,没有。它们是两种不同的语言和环境。为了使用其中一个的信息,您必须使用 VBA 将数据发送到 SQL 进行处理,或者从 SQL 中提取数据以供 VBA 进行处理。如果您想使用 SQL 来处理此问题,有多种解决方案,其中最简单的就是使用记录集的内容填充数据库中的表,然后在查询中使用该表。
In general, no. They are two different languages and environments. In order to use information from one in the other, you either have to use VBA to send data to SQL to process or extract data from SQL to be used by VBA to process. If you wanted to process this using SQL, there are numerous solutions the simplest of which is to populate a table in the database with the contents of your recordset and then use that table in your query.
您有什么类型的记录集,DAO 还是 ADO?
如果您有填充的 ADO 记录集,并且只需要它的子集,则可以使用 RS.Find 查找符合特定条件的单行,或RS.Filter 过滤掉不符合特定条件的每一行。
请注意,这仅适用于 ADO 记录集,不适用于 DAO 记录集!
它不完全是“从 RS 选择 *”,但也许它对您有帮助。
What kind of recordset do you have, DAO or ADO?
If you have a populated ADO recordset and you need only a subset of it, you can use RS.Find to find single rows which match a certain criteria, or RS.Filter to filter out every row which doesn't match a certain criteria.
Be aware that this only works with ADO recordsets, not DAO recordsets!
It' not exactly "Select * from RS", but maybe it helps you.