在 Access 2003/2007 中打开记录集 [英] Open recordset in Access 2003/2007

查看:28
本文介绍了在 Access 2003/2007 中打开记录集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有好几年没有从事 Access 代码工作了,这确实让我发疯了.

It's been years since I've worked in Access code and it is making me certifiably insane.

我只是什么都不记得了,我想做的就是在代码中打开一个记录集,而我在网上找到的任何内容或我尝试过的任何代码排列都不起作用.

I just don't remember anything and all I want to do is open a recordset in code and nothing I've found online or any permutation of code I've tried works.

缺点:

Dim rsSystem As Recordset
Dim sSQL As String

sSQL = "SELECT * FROM Table"
Set rsSystem = CurrentDB.OpenRecordset(sSQL)

我到底错过了什么?

提前致谢.

推荐答案

这里的示例,用于打开记录集"的所有排列:http://www.vbexplorer.com/VBExplorer/vb_feature/june2000/Database_Beginner_ADO_DAO.asp

Examples here, for all permutations of opening a "Recordset": http://www.vbexplorer.com/VBExplorer/vb_feature/june2000/Database_Beginner_ADO_DAO.asp

最简单的方法是在当前数据库上使用DAO.我的 VBA 有点生疏,但是...

The easiest way is to use DAO on the current database. My VBA is a little rusty, but...

Dim db as DAO.Database
Dim rs as DAO.Recordset
Set db = CurrentDB
Set rs = DB.OpenRecordset("table or query name")

对于 ADO:

Dim rs As New ADODB.Recordset
rs.Open "tblPeople", CurrentProject.Connection, adOpenDynamic

这篇关于在 Access 2003/2007 中打开记录集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆